For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > January 2007 > How to add ButtonColumn to GridView Programmatically









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to add ButtonColumn to GridView Programmatically
Joao Rego

2007-01-30, 7:10 pm

Hello,

C# and asp.net 2.0

I have a <asp:GridView> that I create dinamically.
Now I need to add a ButtonColumn to the GridView.

I have this code:

ButtonColumn btColumn = new ButtonColumn();
btColumn.ButtonType = ButtonColumnType.LinkButton;
btColumn.Text = "myText";
btColumn.CommandName = "myCommand";
gridViewDocm.Columns.Add(btColumn); <-- doesn't work!!!!

How do I do this?
It used to work for DataGrid not for GridView!!!

I appreciate any help you can give.
Thanks,
Joao Rego



bruce barker

2007-01-30, 7:10 pm

the gridview does not support button columns. you can add a ButtonField
to its template.

-- bruce (sqlwork.com)

Joao Rego wrote:
> Hello,
>
> C# and asp.net 2.0
>
> I have a <asp:GridView> that I create dinamically.
> Now I need to add a ButtonColumn to the GridView.
>
> I have this code:
>
> ButtonColumn btColumn = new ButtonColumn();
> btColumn.ButtonType = ButtonColumnType.LinkButton;
> btColumn.Text = "myText";
> btColumn.CommandName = "myCommand";
> gridViewDocm.Columns.Add(btColumn); <-- doesn't work!!!!
>
> How do I do this?
> It used to work for DataGrid not for GridView!!!
>
> I appreciate any help you can give.
> Thanks,
> Joao Rego
>
>
>

Joao Rego

2007-01-31, 8:09 am

Hi bruce,

Thanks for the tip.


"bruce barker" wrote:

> the gridview does not support button columns. you can add a ButtonField
> to its template.
>
> -- bruce (sqlwork.com)
>
> Joao Rego wrote:
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com