Dynamic control array & Command Event Handler

S

Sriram

Hi,
I am populating a grid dynamically. Based on the data, I
populate some command buttons (control array) with a
CommandEventHandler assignment for Command event. I could able to see
the button. But CommandEventHandler is not not getting fired.

Here is the code snipet:

if (tempLbl.Text.ToString() == "Y/N")
{
Button adnlInfo1 = new Button();
adnlInfo1.ID = "btnAdnl" + dgRows.ToString();
adnlInfo1.CommandArgument =
dgmgItems.Items[dgRows].Cells[8].Text.ToString();
adnlInfo1.Command += new CommandEventHandler(this.btnAdnl_Command);

adnlInfo1.Text = "*";
btns[dgRows] = adnlInfo1;
dgmgItems.Items[dgRows].Cells[2].Controls.Add(btns[dgRows]);
}

CommandEventHandler is:

protected void btnAdnl_Command(object sender, CommandEventArgs e)
{
string strId = e.CommandArgument.ToString();
}



Could someone help me in this?

TIA

-Sri.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top