Regarding Adding column in a GridView
How can i add a new column to Gridview which is not present in Database?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 13, 2011, 9:37 PM EDT
DataTable dt = new DataTable("TableName");
DataColumn dc;
for (int i = 0; i < 10; i++)
{
dc = new DataColumn(i.ToString());
}
dt.Columns.Add(dc);
MyGridView1.DataSource = dt;
MyGridView1.DataBind();
------------------------------------
If this helps you, then mark as "Correct Answer"