Dynamically bound column in Gridview

S

sivagururaja

Hi All,

How can i bound the column in the gridview dynamically.
When i tried to bound the column using the Code behind, it won't work.
Here is my code.
BoundColumn bc = new BoundColumn();
bc.HeaderText = "Names";
bc.DataField = "Name";
GridView1.Columns.Add(bc);
What's the mistake i made in this?

My problem is, I maintain the two type of Users in my page.
One is normal users and another one is Power user.
When the normal users are loged on only the columns i mentioned as per
the ASP page will be bound. This work's fine.
On the other hand, when the Power user will logged on it will bound
the columns via the code behind.

Regards,
Raja.
 
M

Mark Rae

How can i bound the column in the gridview dynamically.
When i tried to bound the column using the Code behind, it won't work.
Here is my code.
BoundColumn bc = new BoundColumn();
bc.HeaderText = "Names";
bc.DataField = "Name";
GridView1.Columns.Add(bc);
What's the mistake i made in this?

In which method on the page are you running this code...? E.g. Page_Init,
Page_Load etc...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top