Hi,

My "master" gridview is "grd_EmployeePlanningShow", bound to a sqldatasource containig departments of company.
When the user does click on expand image of the "master" gridview, the "child" gridview is bounded with the relative info columns (of selected department),
as you can see in my aspx code.
What i wish to do is edit the "Budget" column from the child gridview.
When i click on the "Modify Budget", button nothing happens; i also set a breackpoint in my "..._RowEditing" procedure, and i see that is never fired.
Can anyone help me?

Thank you!

.aspx

Code:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<html>
<head>
    <style type="text/css">
    .verdana_small
        {
            font-family:Verdana;
            font-size:small;
        }
    </style>
	
     <script type="text/JavaScript" language="JavaScript">
         function switchViews(obj, row) {
             var div = document.getElementById(obj);
             var img = document.getElementById('img' + obj);

             if (div.style.display == "none") {
                 div.style.display = "inline";
                 img.src = "../Images/expand_button_down.png";
             }
             else {
                 div.style.display = "none";
                 img.src = "../Images/expand_button.png";
             }
         }
     </script>
</head>
<body>
<form method="post" action="Recruitment.aspx" onsubmit="javascript:submitRequest()">
    <br/>
    <p class="center"><b>Planning</b></p>

    <asp:UpdatePanel ID="UpdatePanel2" runat="server">

    <ContentTemplate>
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
    <br/>
	
    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Width="1365" AutoPostBack="True" CssClass ="verdana_small">

    <asp:TabPanel runat="server"  ID="tab_Recruitment">
    <ContentTemplate>

<asp:Panel ID="panel1" runat="server">

    <asp:DropDownList ID="drp_MonthPlan" runat="server"
        onselectedindexchanged="drp_MonthPlan_SelectedIndexChanged"
        AutoPostBack="True">
        <asp:ListItem Value="0">--</asp:ListItem>
        <asp:ListItem Value="1">January</asp:ListItem>
        <asp:ListItem Value="2">February</asp:ListItem>
        <asp:ListItem Value="3">March</asp:ListItem>
        <asp:ListItem Value="4">April</asp:ListItem>
        <asp:ListItem Value="5">May</asp:ListItem>
        <asp:ListItem Value="6">June</asp:ListItem>
        <asp:ListItem Value="7">July</asp:ListItem>
        <asp:ListItem Value="8">August</asp:ListItem>
        <asp:ListItem Value="9">September</asp:ListItem>
        <asp:ListItem Value="10">October</asp:ListItem>
        <asp:ListItem Value="11">November</asp:ListItem>
        <asp:ListItem Value="12">December</asp:ListItem>
    </asp:DropDownList>
</asp:Panel>
	
<asp:Panel ID="pnl_EmployeePlanningShow" runat="server" CssClass="verdana_small">
<br/>
<asp:GridView ID="grd_EmployeePlanningShow" runat="server" AutoGenerateColumns = "False"
    DataKeyNames = "Department"
    DataSourceID="sourceDepartments"
    onrowdatabound="grd_EmployeePlanningShow_RowDataBound"
    EmptyDataText="Check positions master data imports!">
    <Columns>
           <asp:TemplateField>
                <ItemTemplate>
                    <a href="javascript:switchViews('div<%# Eval("department") %>', 'one');">
                        <img src="../Images/expand_button.png" alt="+/-" id='imgdiv<%# Eval("department") %>' border="0" width="25px"/>
                    </a>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>

            <asp:BoundField DataField="department" HeaderText="Department" HtmlEncode="False" />

            <asp:TemplateField HeaderText="Employee Personal Planning">
                <ItemTemplate>
                    <div id="div<%# Eval("department") %>" style="display:none" >
                    <asp:GridView ID="grd_EmployeePlanningShowChild" runat="server" DataKeyNames = "id_position,id_emp_planning" AutoGenerateColumns = "False"
                            EnableModelValidation="True" ShowFooter="True" Width = "1000px"
                            onrowdatabound="grd_EmployeePlanningShowChild_RowDataBound"
                            OnRowCommand="grd_EmployeePlanningShowChild_RowCommand"
                            OnRowEditing="grd_EmployeePlanningShowChild_RowEditing"
                            OnRowCancelingEdit = "grd_EmployeePlanningShowChild_RowCancelingEdit"
                            OnRowUpdating = "grd_EmployeePlanningShowChild_RowUpdating"
                            ondatabound="grd_EmployeePlanningShowChild_DataBound">
                    <Columns>
                       <asp:BoundField DataField="id_position" Visible ="false"/>
                       <asp:BoundField DataField="subdepartment" HeaderText="Team" HeaderStyle-Width="150px" ItemStyle-Width="200px" ReadOnly="True"/>
                       <asp:BoundField DataField="position_name" HeaderText="Position" HeaderStyle-Width="150px" ItemStyle-Width="200px" ReadOnly="True"/>

                       <asp:TemplateField HeaderText ="Budget">
                           <ItemTemplate>
                                <asp:Label ID="lbl_target" runat="server" Text='<%# Eval("target")%>'> </asp:Label>
                           </ItemTemplate><ItemStyle HorizontalAlign="Center" Width="30px" ></ItemStyle>
                           <EditItemTemplate>
                                <asp:TextBox ID="txt_target" Text='<%# Eval("target") %>' runat="server" Width="30px" MaxLength = "4"/>
                           </EditItemTemplate>
                        </asp:TemplateField>

                       <asp:BoundField DataField="actual" HeaderText="Actual" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Center" Width="30px"></ItemStyle>
                       </asp:BoundField>
                                   
                       <asp:BoundField DataField="Diff" HeaderText="Difference" ReadOnly="True">
                            <ItemStyle HorizontalAlign="Center" Font-Bold="true" Width="30px"/>
                       </asp:BoundField>

                       <asp:BoundField DataField="id_emp_planning" Visible ="false"/>

                       <asp:CommandField ButtonType="Button" ShowEditButton="True" EditText="Modify Budget">
                           <ItemStyle Width="50px"/>
                       </asp:CommandField>

                       <%-- <asp:ButtonField Text="Modify Budget" CommandName="EditRow" ButtonType="Button" /> --%>

                   </Columns>
                   <FooterStyle BackColor="Silver" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" Wrap="True" />
                   <HeaderStyle BackColor="#FF6600" ForeColor="White" />
                   </asp:GridView>
                   </div>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>

    </Columns>
    <EmptyDataRowStyle BackColor="#FF6600" />
    <HeaderStyle BackColor="Indigo" ForeColor="White" />
    </asp:GridView>
	<br/>
    </asp:Panel>
	
	</ContentTemplate>
    </asp:TabPanel>
	
	<asp:TabPanel runat="server" HeaderText="tab 3" ID="tab_InWork" Visible="false">
        <ContentTemplate>
        </ContentTemplate>
    </asp:TabPanel>

    </asp:TabContainer>

    </ContentTemplate>
    </asp:UpdatePanel>

    </form>
	
	</body>
</html>
C#

Code:
protected void grd_EmployeePlanningShow_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GridView grd_EmployeePlanningShowChild = (GridView)e.Row.Cells[2].Controls[1];

                string id_department = grd_EmployeePlanningShow.DataKeys[e.Row.DataItemIndex].Value.ToString();
                sourceEmployeePlanningShow.SelectParameters["id_department"].DefaultValue = id_department;

                string month = drp_MonthPlan.SelectedValue.ToString();
                sourceEmployeePlanningShow.SelectParameters["month"].DefaultValue = month;

                object data = sourceEmployeePlanningShow.Select(DataSourceSelectArguments.Empty);
                grd_EmployeePlanningShowChild.DataSource = data;
                grd_EmployeePlanningShowChild.DataBind();

                //grd_EmployeePlanningShowChild.Columns[0].Visible = false;
            }
        }

		protected void grd_EmployeePlanningShowChild_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            const int DIFF_COLUMN = 5;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.DataItem != null)
                {
                    try
                    {
                        if (Int32.Parse(e.Row.Cells[DIFF_COLUMN].Text) < 0)
                        {
                            e.Row.Cells[DIFF_COLUMN].ForeColor = System.Drawing.Color.Red;
                        }
                        if (Int32.Parse(e.Row.Cells[DIFF_COLUMN].Text) > 0)
                        {
                            e.Row.Cells[DIFF_COLUMN].ForeColor = System.Drawing.Color.Blue;
                        }
                        if (Int32.Parse(e.Row.Cells[DIFF_COLUMN].Text) == 0)
                        {
                            //e.Row.Cells[DIFF_COLUMN].BackColor = System.Drawing.Color.ForestGreen;
                            //e.Row.Cells[DIFF_COLUMN].Text = "OK";
                            e.Row.Cells[DIFF_COLUMN].ForeColor = System.Drawing.Color.ForestGreen;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }

        protected void grd_EmployeePlanningShowChild_DataBound(object sender, EventArgs e)
        {
            foreach (GridViewRow row in grd_EmployeePlanningShow.Rows)
            {
                int total_target = 0;
                int total_actual = 0;
                int total_difference = 0;

                GridView g = (GridView)row.Cells[1].FindControl("grd_EmployeePlanningShowChild");

                foreach (GridViewRow gvr2 in g.Rows)
                {
                    Label lbl_target = gvr2.Cells[3].FindControl("lbl_target") as Label;

                    int _target = Int32.Parse(lbl_target.Text);
                    total_target += _target;

                    int _actual = Int32.Parse(gvr2.Cells[4].Text);
                    total_actual += _actual;

                    int _difference = Int32.Parse(gvr2.Cells[5].Text);
                    total_difference += _difference;
                }

                GridViewRow footer = g.FooterRow;

                //footer.Cells[0].ColumnSpan = 2;
                footer.Cells[2].Text = "Total: ";
                footer.Cells[3].Text = total_target.ToString();
                footer.Cells[4].Text = total_actual.ToString();
                footer.Cells[5].Text = total_difference.ToString();
            }
        }
		
protected void grd_EmployeePlanningShowChild_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row_FromParentGrid = (GridViewRow)((Control)e.CommandSource).Parent.Parent;
            GridView grd_ParentGrid = (GridView)((Control)e.CommandSource).Parent.Parent.Parent.Parent;

            int index_ParentRow = row_FromParentGrid.RowIndex;

            string s = grd_ParentGrid.DataKeys[index_ParentRow][0].ToString();
            string ss = drp_MonthPlan.SelectedValue.ToString();

            sourceEmployeePlanningShow.SelectParameters["id_department"].DefaultValue = s;
            sourceEmployeePlanningShow.SelectParameters["month"].DefaultValue = ss;
		}
		
public void BindGridView_sourceAssessmentShow(GridView gg)
        {
            gg.DataSource = sourceEmployeePlanningShow;
            gg.DataBind();
        }
		
protected void grd_EmployeePlanningShowChild_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView gg = (GridView)sender;
            gg.EditIndex = e.NewEditIndex;
            BindGridView_sourceAssessmentShow(gg);
		}
protected void grd_EmployeePlanningShowChild_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            GridView gg = (GridView)sender;
            gg.EditIndex = -1;
            BindGridView_sourceAssessmentShow(gg);
			
            //grd_EmployeePlanningShow_DataBound(sender, e);
        }
		
protected void grd_EmployeePlanningShowChild_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int index = e.RowIndex;
            GridView gg = (GridView)sender;

            GridViewRow currentrow = gg.Rows[index];

            TextBox txt_new_target = currentrow.FindControl("txt_target") as TextBox;

            if (!String.IsNullOrEmpty(txt_new_target.Text))
            {
                if ((isNumeric(txt_new_target.Text, System.Globalization.NumberStyles.Integer)))
                {
                    SqlConnection cnn = new SqlConnection();
                    cnn.ConnectionString = ConfigurationManager.ConnectionStrings["login_ConnecString"].ConnectionString;
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = cnn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "update_EmployeePlanTarget";

                    SqlParameter p = new SqlParameter();
                    p.ParameterName = "@id_emp_planning";
                    p.Value = Convert.ToInt32(gg.DataKeys[index][1]);
                    cmd.Parameters.Add(p);

                    p = new SqlParameter();
                    p.ParameterName = "@new_target";
                    p.Value = Convert.ToInt32(txt_new_target.Text);
                    cmd.Parameters.Add(p);

                    try
                    {
                        cnn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        cnn.Close();
                    }

                    gg.EditIndex = -1;
                    BindGridView_sourceAssessmentShow(gg);

                    grd_EmployeePlanningShow.DataBind();

                    //MessageBox.Show("Employee planned target changed!");
                }
                else
                    MessageBox.Show("Please introduce a numeric value!");
            }
            else
                MessageBox.Show("Please introduce a numeric value!");
        }