|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dynamically create datagrid and set its datasource in VB.NETtry to setup the datasource, the DATASOURCE is not the property of datagrid. Anybody know the reason? Here is my code: Public Sub CreateGrid() 'declare a new datagrid and set properties Dim DataGrid1 As New DataGrid() DataGrid1.ShowHeader = True DataGrid1.AutoGenerateColumns = False DataGrid1.SelectedItemStyle.BackColor = Color.Yellow 'add bound columns to the datagrid Dim datagridcol As New BoundColumn() datagridcol.HeaderText = "Last Name" datagridcol.DataField = "lastname" DataGrid1.Columns.Add(datagridcol) datagridcol = New BoundColumn() datagridcol.HeaderText = "First Name" datagridcol.DataField = "firstname" DataGrid1.Columns.Add(datagridcol) 'bind datagrid '************************************* 'I will get error in here and tell me that 'datasource is not the property of DataGrid1 DataGrid1.DataSource = GetDataSet() DataGrid1.DataBind() 'add datagrid to the page Page.Controls(1).Controls.Add(DataGrid1) End Sub I tried the same thing in C#, the DATASOURCE is the property of datagrid and it works great. thanks for any help I found that I have another class also called datagrid which caused
that there is no datasource property. I should use the full name like system.web.ui.controls.datagrid to declare it. Donna wrote: Show quoteHide quote > I try to dynamically add datagrid to my web form in VB.NET. But when I > > try to setup the datasource, the DATASOURCE is not the property of > datagrid. Anybody know the reason? Here is my code: > > Public Sub CreateGrid() > 'declare a new datagrid and set properties > Dim DataGrid1 As New DataGrid() > DataGrid1.ShowHeader = True > DataGrid1.AutoGenerateColumns = False > DataGrid1.SelectedItemStyle.BackColor = Color.Yellow > > 'add bound columns to the datagrid > Dim datagridcol As New BoundColumn() > datagridcol.HeaderText = "Last Name" > datagridcol.DataField = "lastname" > DataGrid1.Columns.Add(datagridcol) > > datagridcol = New BoundColumn() > datagridcol.HeaderText = "First Name" > datagridcol.DataField = "firstname" > DataGrid1.Columns.Add(datagridcol) > > 'bind datagrid > '************************************* > 'I will get error in here and tell me that > 'datasource is not the property of DataGrid1 > DataGrid1.DataSource = GetDataSet() > DataGrid1.DataBind() > > 'add datagrid to the page > Page.Controls(1).Controls.Add(DataGrid1) > > End Sub > > I tried the same thing in C#, the DATASOURCE is the property of > datagrid and it works great. > > > thanks for any help I'm glad you finally figure it out yourself.
>-----Original Message----- full name like>I found that I have another class also called datagrid which caused >that there is no datasource property. I should use the >system.web.ui.controls.datagrid to declare it. VB.NET. But when> > >Donna wrote: >> I try to dynamically add datagrid to my web form in Show quoteHide quote >I >> >> try to setup the datasource, the DATASOURCE is not the property of >> datagrid. Anybody know the reason? Here is my code: >> >> Public Sub CreateGrid() >> 'declare a new datagrid and set properties >> Dim DataGrid1 As New DataGrid() >> DataGrid1.ShowHeader = True >> DataGrid1.AutoGenerateColumns = False >> DataGrid1.SelectedItemStyle.BackColor = Color.Yellow >> >> 'add bound columns to the datagrid >> Dim datagridcol As New BoundColumn() >> datagridcol.HeaderText = "Last Name" >> datagridcol.DataField = "lastname" >> DataGrid1.Columns.Add(datagridcol) >> >> datagridcol = New BoundColumn() >> datagridcol.HeaderText = "First Name" >> datagridcol.DataField = "firstname" >> DataGrid1.Columns.Add(datagridcol) >> >> 'bind datagrid >> '************************************* >> 'I will get error in here and tell me that >> 'datasource is not the property of DataGrid1 >> DataGrid1.DataSource = GetDataSet() >> DataGrid1.DataBind() >> >> 'add datagrid to the page >> Page.Controls(1).Controls.Add(DataGrid1) >> >> End Sub >> >> I tried the same thing in C#, the DATASOURCE is the property of >> datagrid and it works great. >> >> >> thanks for any help > >. >
Searched Datagrid with Paging?
Using Server.Transfer with HyperLinkColumn in a datagrid Questions concerning detailsview or datagrid ASP.NET 2.0 Export to PDF How can I export a Dataview to Excel How to capture CheckChanged event from Radiobutton in Datagrid? Showing x to y of z records Fonction de recherche dans un datagrid search function on different page selected "Single record" edit control |
|||||||||||||||||||||||