|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Datagrid not displayingDATAGRID. My code is below: Imports System Imports System.Data.SqlClient Imports System.Data Imports System.Web Imports System.Web.Security Imports System.ComponentModel Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Xml Imports System.Web.HttpApplication Namespace OARSControls Public Class MyList : Inherits DataGrid Protected Overrides Sub OnInit(ByVal e As EventArgs) Dim objFormsID As FormsIdentity objFormsID = Context.User.Identity Context.Trace.Warn("Start") Dim SQLConn_MyConn As New System.Data.SqlClient.SqlConnection("...MyConnection...") Context.Trace.Warn("SQLConn") Dim SqlCmd_uspTheList As New System.Data.SqlClient.SqlCommand Dim SqlDataSet_uspTheList As New DataSet Dim SqlDataAdapter_uspTheList As New System.Data.SqlClient.SqlDataAdapter Context.Trace.Warn("Got through Dims") Context.Trace.Warn("Made Conn String") SqlCmd_uspTheList.CommandText = "uspTheList" SqlCmd_uspTheList.CommandType = System.Data.CommandType.StoredProcedure SqlCmd_uspTheList.Connection = SQLConn_MyConn SqlCmd_uspTheList.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, "")) SqlCmd_uspTheList.Parameters("@ID").Value = objFormsID.Ticket.UserData Context.Trace.Warn("Made SQLCMD") SqlDataAdapter_uspTheList.SelectCommand = SqlCmd_uspTheList SqlDataSet_uspTheList.DataSetName = "SQLDataSet_uspTheList" SqlDataSet_uspTheList.Locale = New System.Globalization.CultureInfo("en-US") Context.Trace.Warn("Making DB Connection") SQLConn_MyConn.Open() Context.Trace.Warn("Making Filling Dataset") SqlDataAdapter_uspTheList.Fill(SqlDataSet_uspTheList) SQLConn_MyConn.Close() DataSource = SqlDataSet_uspTheList DataMember = "table" DataKeyField = "ID" Visible = True Context.Trace.Warn("Okay...") End Sub End Class End Namespace I then add the object to my web page using register tag prefix etc, and the page loads fine...except that no datagrid displays. When I do a page trace I see that my custom control OnInit code ran fine...data was returned and everything...what am I doing wrong? Thanks, Ryan Ok, so an interesting discovery...if I say databind() in my form's
onload event things seem to work fine...however I do not want to bind my whole form...how can I access JUST my newly added control. Attempting to reference it by the ID I gave it does not seem to work. i.e. Mycontrol1.databind() - what I was doing before - does not work. thanks again! Ok, so for those of you out there who may experience this same problem,
I am not sure why I cannot refence the object directly by ID in the code behind, BUT I can reference it using FindControl(ControlID). This allows me to databind. The last issue, in Visual Studio's design view, the control is displayed as ERROR CREATING CONTROL. Since this is just a type of datagrid, and since it does display properly when I actually run the page, does anyone know why the control cannot be rendered in design view? Thanks, Ryan
treeview asp.net 2.0
Menu Control - SubItem Shadows TreeView with custom HierarchicalDataSourceControl Telling weither the control is in design time or on a web page How do I reference or change formview child controls in code? Reading / Modifying FormView Child Controls at Runtime Gridview hypterlink colomn to popup a new window DataGrid event handlers are being lost during re-compile how to mention the date range in the calendar control Calendar control question |
|||||||||||||||||||||||