By DataGrid

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hello,
In a WebForm's DataGrid,one Link button is Ok,but changed this Link button
to Push button,on click this button,this button will no reacting,and no run
this button's ItemCommand procedure.
I use C#.
Can you help me
 
U Need to set ComandName property.
1)In ur case set it to BtnOkDG
2) In ItemCommand Event for Datagrid Check the following
if(e.CommandName=="BtnOkDG")
{
//Process ur Event
}

Eg
private void dg_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="BtnOkDG")
{
dg.SelectedIndex = e.Item.ItemIndex;
//do ur Event prcessing for Ok Button here.
}
}

Hope this helps.

Thanks,

sswalia
MCSD, MCAD, OCA
 
Thank you,
but
What's means Eg?
I set the button's name "BtnOkDG"
and I wrote this code:
private void dg_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="BtnOkDG")
{
abcd.a = e.Item.Cells[1].Text;
Response.Redirect("WebForm2.aspx");
}
}

But on click push button,this procedure is no run.
Can you help me
 
Did u attached this event ItemCommand with datagrid. Please attach it.
to attach use the below code in InitializeComponent()
this.dg.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.dg_ItemCommand);

Thanks,

sswalia
 
I am sorry to say but Jack, you need to pick up a book or take a long drive
through the MSDN. Look for how to attach an event handler.
Prodip
 
Back
Top