NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Tue
8
May '07

How to access items in a GridView?

Like this:

foreach (GridViewRow gvr in GridView1.Rows)
        {
            TextBox t = (TextBox)gvr.Cells[0].Controls[0];
          //  Response.Write("<br />" + t.Text);
        }
'

How to add columns dynamically on a GridView?

Here is the way to add a template column to GridView dynamically (runtime):

 TemplateField tf = new TemplateField();
            tf.HeaderText = “NewTemplate column”;
            MyTemplate template = new MyTemplate(“test”);
            tf.ItemTemplate = template;
            GridView1.Columns.Clear();
            GridView1.Columns.Add(tf);
 
            string[] s = { “as”, “34″, “z”, “@#4″, “666″ };
            GridView1.DataSource = s;
            GridView1.DataBind();
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website