Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > my datagrid does not show up when used as custom control

Reply
Thread Tools

my datagrid does not show up when used as custom control

 
 
Sumana
Guest
Posts: n/a
 
      01-27-2004
Below is the code, for the datagrid custom control. When i view this
in a aspx page, the text "Hello" shows up but not the datagrid. Anyone
can tell me why?
thanks
sumana

Imports System.ComponentModel
Imports System.Web.UI
Imports System
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")> Public Class
WebCustomControl1
Inherits System.Web.UI.WebControls.DataGrid
Dim _text As String
Dim grid As New DataGrid()
Dim cn As New SqlClient.SqlConnection("Initial Catalog=LFBP01;Data
Source=brkdbdn61\brksql01;User Id=YYYD368S;Password=YYYD368S")
Dim da As New SqlClient.SqlDataAdapter("select buyer_cd,buyer_nme
from lftp100_buyer", cn)
Dim DS As New DataSet()

<Bindable(True), Category("Appearance"), DefaultValue("")>
Property [Text]() As String
Get
Return _text
End Get

Set(ByVal Value As String)
_text = Value
End Set
End Property

Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.Write([Text])
da.Fill(DS)
grid.DataSource = DS
grid.DataBind()
grid.Visible = True
grid.BorderStyle = BorderStyle.Solid
End Sub

End Class
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-27-2004
there is no data in your dataset, modify your code to test for data before
you bind
if(DS != null && DS.Tables[0].Rows.Count > 0)
then bind
otherwise
don't bind

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Sumana" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> Below is the code, for the datagrid custom control. When i view this
> in a aspx page, the text "Hello" shows up but not the datagrid. Anyone
> can tell me why?
> thanks
> sumana
>
> Imports System.ComponentModel
> Imports System.Web.UI
> Imports System
> Imports System.Web
> Imports System.Web.UI.WebControls
> Imports System.Web.UI.HtmlControls
> Imports System.Web.SessionState
> Imports System.Data
> Imports System.Data.SqlClient
>
> <DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1
> runat=server></{0}:WebCustomControl1>")> Public Class
> WebCustomControl1
> Inherits System.Web.UI.WebControls.DataGrid
> Dim _text As String
> Dim grid As New DataGrid()
> Dim cn As New SqlClient.SqlConnection("Initial Catalog=LFBP01;Data
> Source=brkdbdn61\brksql01;User Id=YYYD368S;Password=YYYD368S")
> Dim da As New SqlClient.SqlDataAdapter("select buyer_cd,buyer_nme
> from lftp100_buyer", cn)
> Dim DS As New DataSet()
>
> <Bindable(True), Category("Appearance"), DefaultValue("")>
> Property [Text]() As String
> Get
> Return _text
> End Get
>
> Set(ByVal Value As String)
> _text = Value
> End Set
> End Property
>
> Protected Overrides Sub Render(ByVal output As
> System.Web.UI.HtmlTextWriter)
> output.Write([Text])
> da.Fill(DS)
> grid.DataSource = DS
> grid.DataBind()
> grid.Visible = True
> grid.BorderStyle = BorderStyle.Solid
> End Sub
>
> End Class



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nero: MB used bar does not show correct 4 DVDs? Nero 6 lbbss Computer Support 0 03-14-2007 03:18 AM
Datagrid in Custom Server control Does not show ton ASP .Net Building Controls 1 01-27-2004 03:51 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net Building Controls 1 07-02-2003 08:05 AM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments