GridView (A to Z)+Sourabh
-
I have created a gridView at run time like this:
Dim dgUserGrid As GridView dgUserGrid = New GridView dgUserGrid.ID = 5 dgUserGrid.AutoGenerateColumns = False dgUserGrid.BackColor = Drawing.Color.Brown dgUserGrid.ForeColor = Drawing.Color.White dgUserGrid.AllowSorting = True dgUserGrid.AlternatingRowStyle.BackColor = Drawing.Color.BurlyWood
also added this: Protected WithEvents dgUserGrid As System.Web.UI.WebControls.GridView dssave.Tables("dtUsers").Rows.Add() dssave.Tables("dtUsers").Rows(0)("UserName") = name.Text.Trim dssave.Tables("dtUsers").Rows(0)("cPassword") = password.Text.Trim dssave.Tables("dtUsers").Rows(0)("Role") = Role.SelectedItem.Text.Trim dssave.Tables("dtUsers").Rows(0)("PasswordChanged") = 0 Dim userdetgrid As GridView = GridHolder.FindControl(5) userdetgrid.DataSource = dssave.Tables("dtUsers") userdetgrid.DataBind() this code is working fine but not appropriate. I want to create boundcolumns at runtime.??????Thanks and Regards,
-
I have created a gridView at run time like this:
Dim dgUserGrid As GridView dgUserGrid = New GridView dgUserGrid.ID = 5 dgUserGrid.AutoGenerateColumns = False dgUserGrid.BackColor = Drawing.Color.Brown dgUserGrid.ForeColor = Drawing.Color.White dgUserGrid.AllowSorting = True dgUserGrid.AlternatingRowStyle.BackColor = Drawing.Color.BurlyWood
also added this: Protected WithEvents dgUserGrid As System.Web.UI.WebControls.GridView dssave.Tables("dtUsers").Rows.Add() dssave.Tables("dtUsers").Rows(0)("UserName") = name.Text.Trim dssave.Tables("dtUsers").Rows(0)("cPassword") = password.Text.Trim dssave.Tables("dtUsers").Rows(0)("Role") = Role.SelectedItem.Text.Trim dssave.Tables("dtUsers").Rows(0)("PasswordChanged") = 0 Dim userdetgrid As GridView = GridHolder.FindControl(5) userdetgrid.DataSource = dssave.Tables("dtUsers") userdetgrid.DataBind() this code is working fine but not appropriate. I want to create boundcolumns at runtime.??????Thanks and Regards,
Dim grid As New GridView Dim b1 As New BoundField b1.HeaderText = "SerialNo" b1.DataField = "SerialNo" grid.Columns.Add(b1) grid.Columns.Add(b2) God is always with you.