Hi ,
Please tell me how to access linkbutton in a gridview at row command event?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 11, 2011, 10:13 PM EST
Please refer the below link
http://www.aspdotnetcodes.com/ReadTips_Get_GridView_RowIndex_RowCommand_Event.aspx
http://www.aspsnippets.com/Articles/ASP.Net-GridView---Get-Row-Index-on-RowCommand-and-Click-events.aspx
Thanks
Pankaj RanaRank #2,270 · 620 reputationPosted Dec 11, 2011, 10:16 PM EST
Linkbutton in a gridview at row command event can be access which the help of CommandName
propery of LinkButton
as
}
Nethra R SRank #6,347 · 269 reputationPosted Dec 11, 2011, 10:33 PM EST
My linkbutton is in the Gridview footer template like this:
I have one linkbutton in empty data template
At the row command event of of the linkbutton in the empty data template i want to access the link button from footer template
<%--
Nethra R SRank #6,347 · 269 reputationPosted Dec 12, 2011, 1:00 AM EST
I want to access the linkbutton by its ID not by CommandName and that too at RowCommand Event
Pankaj RanaRank #2,270 · 620 reputationPosted Dec 12, 2011, 7:54 PM EST
This code can solve you problem
protected void Grid1_RowCommand(object sender,GridViewCommandEventArgs e)
{
LinkButton lnkAdd=(LinkButton)grdRecipe.FooterRow.FindControl("lnkadd");
Response.Write(lnkAdd.Text);//Print add on browser
}
Nethra R SRank #6,347 · 269 reputationPosted Dec 12, 2011, 11:42 PM EST
Ur code gives object reference not set error