|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ASP.Net/C# - Adding LinkButton's EventHandler inside GridView not working
Hi,
I'm having some trouble adding the linkbutton's Click eventhandler inside gridview's cells. Here is what I have: Code:
private void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton tempLB = new LinkButton();
tempLB.Text = e.Row.Cells[0].Text;
tempLB.Enabled = true;
tempLB.Font.Bold = true;
tempLB.Click += new EventHandler(tempLB_Click);
e.Row.Cells[0].Controls.Add(tempLB);
}
}
private void tempLB_Click(object sender, EventArgs e)
{
message.Text += "!!!!!!";
}
I can see the linkbuttons inside gridview, and the linkbuttons are clickable. However, I don't think the click event handler is working. tempLB_Click method is not called when I click the buttonlinks. Am I missing something? Btw, I'm working on the sharepoint webpart, so no asp aspx page is available. Thanks in advance. |
|
#2
|
||||
|
||||
|
You've to write a handler for the GridView's RowCommand event an hook the handler onto the event to catch anything that triggers an event inside the GridView. Remember to assign a command name to your LinkButton by setting the tempLB.CommandName property and check for that in the event handler. For further explanation on the RowCommand event, click the link or Google it
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > ASP.Net/C# - Adding LinkButton's EventHandler inside GridView not working |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|