Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All

I want to Find Control in gridview on RowCommand event in asp.net
if it Is possible Please revert
Posted

gRow = (GridViewRow) e.CommandSource
TextBox txtAbc= (TextBox)gRow.FindControl("txtAbc");
 
Share this answer
 
Comments
Maddy_1008 10-May-11 1:53am    
thanks for reply mdusara84

But it is not working
gRow not giving me findControl method

please help me
[no name] 10-May-11 3:25am    
GridViewRow gRow;
just add this line before gRow = (GridViewRow)...
 
Share this answer
 
Comments
Maddy_1008 10-May-11 2:06am    
it is also not working
Mahendra.p25 10-May-11 2:30am    
post your code
this is my code.use this help full

protected void gvViewUser_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "delete")
{
GridView gv = (GridView)(Object)sender;
HiddenField hfAccid = (HiddenField)gv.NamingContainer.FindControl("hfAccid");
int res = objAccAssign.DeleteAssignAccount(int.Parse(hfAccid.Value), int.Parse(e.CommandArgument.ToString()));

if (res > 0)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Msg", "alert('User removed successfully !!')", true);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Msg", "alert('User removed failed !!')", true);
}


DataTable dt = objAccAssign.getGridForDataList(hfAccid.Value);

bindGrid(gv, dt);
}
}
catch (Exception ex)
{


}
}
 
Share this answer
 
v2
First u have to give CommandName and CommandArgument property in source file like this

XML
<Columns>
   <asp:TemplateField>
   <ItemTemplate>

       <asp:LinkButton ID="LBviewreport" CommandName="Viewreport" CommandArgument='<%#Eval("Your Table Column Name") %>' runat="server">View Report</asp:LinkButton>

       </ItemTemplate>

   </asp:TemplateField>


then on rowcommand event

C#
protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       if (e.CommandName == "Viewreport")
       {
           string str =  e.CommandArgument.ToString();
             //write Your conditions
                  }
}
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900