| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
A sample code to Add two DataTables in a datagrid using bound columns
<!asp
ataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 278px; POSITION: absolute; TOP: 81px" runat="server" AutoGenerateColumns="false ...A sample code to Add two DataTables in a datagrid using bound columns ? Create a main Page (Drag and drop Datagrid on the design view ) ? Change the Datagrid Autogenerate Property = false) ? The demonstartion creates a Datagrid Bound Columns dynamically and add two datatables to one datagrid [bold]Step 1: main.aspx[/bold] [code] <asp ataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 278px; POSITION: absolute; TOP: 81px" runat="server" AutoGenerateColumns="false"></asp ataGrid> [bold]Step 2: main.aspx.vb [/bold] Try Dim mycn As New System.Data.SQLClient.SqlConnection("server=localhost;uid=sa;password=;database=northwi nd;") Dim myda As New System.Data.SQLClient.SqlDataAdapter("Select productid,categoryid,productname from Products ", mycn) Dim myda1 As New System.Data.SQLClient.SqlDataAdapter("Select categoryid from Categories ", mycn) Dim ds As New System.Data.DataSet() myda.Fill(ds, "Products") myda1.Fill(ds, "Categories") Dim objbc As BoundColumn Dim dc As DataColumn Dim dt As DataTable For Each dt In ds.Tables For Each dc In dt.Columns objbc = New BoundColumn() objbc.HeaderText = dc.ColumnName objbc.DataField = dc.ColumnName DataGrid1.Columns.Add(objbc) Next Next DataGrid1.DataSource = ds.Tables(0) DataGrid1.DataBind() Catch ex As Exception Response.Write(ex.Message & ex.StackTrace) End Try Read Complete Article |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > A sample code to Add two DataTables in a datagrid using bound columns |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|