G
Guest
I have a link button "lButton" created dynamically at the item databound
event of the data grid "datagrid1" in the footer.so i want to execute the
item command event of the datagrid on clicking the dynamicaly created link
button, but when at runtime i click the dymanic created control it disapears
from the datagrid footer and then it doesnt fire the itemcommand event of the
datagrid.
I am pasting below the pieces of my code for your better understanding.
//creating the dynamic control "lButton" at the footer in the ITEM DATABOUND
EVENT and assigning th events to it.
private void datagrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Footer)
{
LinkButton lButton=new
LinkButton();
lButton.Text ="Add Details
here";
lButton.ID ="flagbutton";
lButton.CommandName="flagButton";
lButton.Click +=new System.EventHandler(this.lButton_Click);
e.Item.Cells[2].Controls.Add(lButton) ;
}
}
//in the ITEM COMMAND EVENT, executing the a logic when teh link button in
the grid gets clciked
private void datagrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(String.Compare(e.CommandName,"flagButton",true)==0)
{
Response.Write("done");
}
}
//Event TO BE EXECUTED BY DYNAMIC CREATED CONTROL lButton
private void lButton_Click(object sender, System.EventArgs e)
{
DataGridCommandEventArgs dgcea = (DataGridCommandEventArgs)e;
datagrid1_ItemCommand(sender, dgcea);
}
so could anyone of you help me out in fixing the problem . and the reson for
this type of cause.
Your expert advice in sorting out thsi issue woudl be highly appreciated.
Rgds
Shiju
event of the data grid "datagrid1" in the footer.so i want to execute the
item command event of the datagrid on clicking the dynamicaly created link
button, but when at runtime i click the dymanic created control it disapears
from the datagrid footer and then it doesnt fire the itemcommand event of the
datagrid.
I am pasting below the pieces of my code for your better understanding.
//creating the dynamic control "lButton" at the footer in the ITEM DATABOUND
EVENT and assigning th events to it.
private void datagrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Footer)
{
LinkButton lButton=new
LinkButton();
lButton.Text ="Add Details
here";
lButton.ID ="flagbutton";
lButton.CommandName="flagButton";
lButton.Click +=new System.EventHandler(this.lButton_Click);
e.Item.Cells[2].Controls.Add(lButton) ;
}
}
//in the ITEM COMMAND EVENT, executing the a logic when teh link button in
the grid gets clciked
private void datagrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(String.Compare(e.CommandName,"flagButton",true)==0)
{
Response.Write("done");
}
}
//Event TO BE EXECUTED BY DYNAMIC CREATED CONTROL lButton
private void lButton_Click(object sender, System.EventArgs e)
{
DataGridCommandEventArgs dgcea = (DataGridCommandEventArgs)e;
datagrid1_ItemCommand(sender, dgcea);
}
so could anyone of you help me out in fixing the problem . and the reson for
this type of cause.
Your expert advice in sorting out thsi issue woudl be highly appreciated.
Rgds
Shiju