all groups > asp.net datagrid control > november 2004 >
You're in the

asp.net datagrid control

group:

ButtonColumn info


ButtonColumn info Steph
11/30/2004 12:00:56 PM
asp.net datagrid control:
Hello,

I have a datagrid dgGrid and want add column depending of a context. I am
usin this following code :

....
while (Clcpt<7)
{
ButtonColumn myCol = new ButtonColumn();
myCol.HeaderText = Clcpt.ToString();
myCol.ButtonType = ButtonColumnType.LinkButton;
myCol.Text = "<img src='images/Add.gif' border=0>";
myCol.CommandName = "cmd"+Clcpt;
Response.Write("cmd"+Clcpt+"/");
dgGrid.Columns.Add(myCol);
Clcpt++;
}
...
Cols are ok but I can't intercept the clik on the button. I have an event
handler dgDrid_ItemCommand but it is never fired ?

Any idea ?

thanks

Re: ButtonColumn info John McCarthy
12/6/2004 7:31:39 PM
Steph

I just ran across your message .....

this message will NOT help you but I wanted to fyi you that
I am trying the same thing (using VB i.e. AddHandler ) and have hit the same
problem ...

additionally, (you'll have to take my word for it)

(a) I own just about ALL the asp.net books out there ....
(I don't read books - I read topics)

(b) Not one of them - (unless I missed it) attempts this ....

(Waltham and Payne are two of the better books out there - if
your goal is to crank up to asp.net )

(c) The standout book (my dumb ass two cents) about GridControls
is Scott Mitchell's - but he does not really pursue the idea of setting ALL
properties, controls, etc. from a CodeBehindPage i.e. his focus
is elsewhere .....

(d) I have spent many hours searching this on google - and cannot
find an example in which this is your HTML page

---------------------
HTML Page
---------------------
<ASP:DATAGRID
id="dg1"
runat="server">
</ASP:DATAGRID>

and everything else happens on the CodeBehindPage ....

(e) which leads me to think .... I am conceptually missing
the *big picture* and just perhaps should accept the idea
that the 5 types of buttons must be initiated in the HTML page ...

If you do find a solution to capturing the Click Event .....
please give me a YELL ...

regards,
John McCarthy





[quoted text, click to view]

RE: ButtonColumn info John
7/1/2005 6:13:35 PM
You need an event handler:

In the code behind sorry for the C#

private void InitializeComponent()
{
this.RouteDataGrid.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.RouteDataGrid_ItemCommand);
}

Hope this helps.

From http://www.developmentnow.com/g/12_2004_11_0_0_6927/ButtonColumn-info.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button