Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Right now we were worked on gridview under three gridviews .Please find below formate.
 
ParentGridview ---MainGrid
ChildGridview1 -----Child1
ChildGridview2 -----Child2
ChildGridview3 -----Child3
 

 
Now we want edit ChildGridview2. how can we get ChildGridview2 edit values in ChildGridview2_Rowcommand.
 
we unable ger e.commandName value in ChildGridview2_Rowcommand
 

protected void ChildGridview2_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
       {
           if (e.CommandName == "Edit")
           {
               int i = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
               int l =((GridViewRow)((GridViewRow)((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).Parent.Parent.Parent.Parent)).RowIndex;
               int m =((GridViewRow)((GridViewRow)((GridViewRow)((ImageButton)e.CommandSource).NamingContainer)).Parent.Parent.Parent.Parent).RowIndex;
               //string ClientID = ((HiddenField)((GridView)ParentGridview.Rows[l].FindControl("ChildGridview1")).Rows[i].FindControl("hfProjectID")).Value;

 

               int EmployeeID = Convert.ToInt32(((HiddenField)((GridView)((GridView)ParentGridview.Rows[l].FindControl("ChildGridview1")).Rows[i].FindControl("ChildGridview2")).Rows[m].FindControl("hfEmpolyeeID")).Value);
 
               int ClientID = Convert.ToInt32(((HiddenField)((GridView)((GridView)ParentGridview.Rows[l].FindControl("ChildGridview1")).Rows[i].FindControl("ChildGridview2")).Rows[m].FindControl("hfclient")).Value);
              string Day = ((HiddenField)((GridView)((GridView)ParentGridview.Rows[l].FindControl("ChildGridview1")).Rows[i].FindControl("ChildGridview2")).Rows[m].FindControl("hfdate")).Value;
              string Query = EmployeeID.ToString()+"/" + ClientID.ToString()+"/" + Day;
 
              Response.Redirect("EditTimecard.aspx?val=" + Query);
 
           }
 
       }
 
please help me..
 
thanks and regards
Posted 28-Feb-13 2:44am
Edited 28-Feb-13 18:33pm
v2
Comments
Dharmendra-18 at 1-Mar-13 0:47am
   
are you using any button inside gridview(parent) or directly click on gridview(parent) to edit child gridview
Santhosh23 at 1-Mar-13 1:53am
   
ya, am using Image button in child gridview.
please see my Gridview structure.
 
<asp:GridView ID="ParentGridview" GridLines="Horizontal" AutoGenerateColumns="false" runat="server"
ShowHeader="false" Width="100%" OnRowDataBound="ParentGridview_RowDataBound" Style="border: none!important;">

<asp:TemplateField ShowHeader="false">


<tr>
<td colspan="5" align="left" valign="top">
<asp:GridView ID="ChildGridview1" GridLines="Horizontal" OnRowDataBound="ChildGridview1_RowDataBound"
OnRowCommand="ChildGridview1_RowCommand" ShowHeader="false" AutoGenerateColumns="false"
runat="server" Width="100%" Style="border: none!important;">

<asp:TemplateField ShowHeader="false">

<table align="left" width="100%">

<tr>
<td colspan="5" align="left" valign="top">
<asp:GridView ID="ChildGridview2" GridLines="None" Width="100%" ShowHeader="true"
OnRowDataBound="ChildGridview2_RowDataBound" Visible="false" OnRowCommand="ChildGridview2_RowCommand" AutoGenerateColumns="false"
runat="server">

<asp:TemplateField ShowHeader="true">


<table width="100%">
<tr>

<td align="left" valign="top" width="1%">
<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="../images/delete-icon.png"
CommandName="" />
<asp:ImageButton ID="imgDelete" runat="server" ImageUrl="../images/gtk-edit.png" />
</td>
<td colspan="5" align="left" valign="top">
<asp:GridView ID="ChildGridview3" GridLines="None" Width="100%" ShowHeader="true"

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 453
1 CPallini 333
2 George Jonsson 270
3 OriginalGriff 159
4 Prasad Khandekar 135
0 OriginalGriff 4,613
1 CPallini 3,340
2 Sergey Alexandrovich Kryukov 2,879
3 George Jonsson 2,264
4 Gihan Liyanage 2,020


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 1 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100