|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid problemWhen binded to a DataGrid, a get the column names in DataTable as headers for the columns in the DataGrid. When I created the DataColumns I set their Caption property, but it doesn't want to show as Column header in the DataGrid. What I do wrong? Code: Dim DS1 As New DataSet Dim dT As New DataTable("Table Name") Dim dCol As DataColumn dCol = New System.Data.DataColumn("Col1") dCol.DataType = System.Type.GetType("System.String") dCol.Caption = "Column 1" dT.Columns.Add(dCol) dCol = New System.Data.DataColumn("Col2") dCol.DataType = System.Type.GetType("System.String") dCol.Caption = "Column 2" dT.Columns.Add(dCol) DS1.Tables.Add(dT) DataGrid1.DataSource = DS1.Tables(0) DataGrid1.DataBind I am not sure but probably you have to use ColumnName property instead
Otabek Nikolay,
In my opinion is in this page exactly described what you want. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridcolumnstyleclassheadertexttopic.asp I hope this helps, Cor What about ASP datagrid?
Show quoteHide quote "Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message news:%23KwYoRpOFHA.3336@TK2MSFTNGP09.phx.gbl... > Nikolay, > > In my opinion is in this page exactly described what you want. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridcolumnstyleclassheadertexttopic.asp > > I hope this helps, > > Cor > Nikolay,
After some trying I succeeded with that. :-) \\\Needs a datagrid on a webformPrivate Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim DS1 As New DataSet Dim dT As New DataTable("Table Name") dT.Columns.Add("Col1", GetType(System.String)) dT.Columns.Add("Col2", GetType(System.String)) dT.LoadDataRow(New Object() {"Nikolay", "Cor"}, True) DS1.Tables.Add(dT) DataGrid1.DataSource = DS1.Tables(0) Dim b1 As New BoundColumn Dim b2 As New BoundColumn b1.DataField = "Col1" b2.DataField = "Col2" b1.HeaderText = "Question" b2.HeaderText = "Answer" DataGrid1.Columns.Add(b1) DataGrid1.Columns.Add(b2) DataGrid1.AutoGenerateColumns = False DataGrid1.DataBind() End Sub /// I hope this helps a little bit? Cor
In-place Updating in Datagrid not working
Why doesn't timer tick Accessing Through Newsreader Data/Business Object Tier Best Practices How to get Enum type using Enum name? Stored Procedure creation in vb.net How to convert a Byte array to a String Multiselect List Box Catching exceptions during DirectoryInfo.GetFiles? dataset xml |
|||||||||||||||||||||||