0

I have problem dealing with EditItemTemplate. What I am trying to do is to update 'lowerIncomeBoundary' with the sum of amount of current value in tb1 and tb2 which is the sum of "lowerIncomeBoundary" and "upperIncomeBoundary". Appreciate if someone can provide me a way to access item in EditItemTemplate...

<asp:TemplateField HeaderText="Chargeable&lt;br/&gt;Income&lt;br/&gt;RM">
                <ItemTemplate>
                    <%# Eval("lowerIncomeBoundary")%><br /><%# Convert.ToInt32(Eval("upperIncomeBoundary")) - Convert.ToInt32(Eval("lowerIncomeBoundary")) %>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox Text='<%#Bind("lowerIncomeBoundary") %>' runat="server" ID="tb1"></asp:TextBox>
                    <asp:TextBox Text='<%#Bind("upperIncomeBoundary") %>' runat="server" ID="tb2"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Derice
0

I found a way to access item in EditItemTemplate. I even get to print the sum of tb1 and tb2 textbox but "upperIncomeBoundary" is not being update. Any idea why this is happening?

<asp:TemplateField HeaderText="Chargeable&lt;br/&gt;Income&lt;br/&gt;RM">
                <ItemTemplate>
                    <%# Eval("lowerIncomeBoundary")%><br /><%# Convert.ToInt32(Eval("upperIncomeBoundary")) - Convert.ToInt32(Eval("lowerIncomeBoundary")) %>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox Text='<%#Bind("lowerIncomeBoundary") %>' runat="server" ID="tb1"></asp:TextBox>
                    <asp:TextBox Text='<%#Convert.ToInt32(Eval("upperIncomeBoundary")) - Convert.ToInt32(Eval("lowerIncomeBoundary")) %>' runat="server" ID="tb2"></asp:TextBox>
                    <asp:TextBox Text='<%#Bind("upperIncomeBoundary") %>' runat="server" ID="tbTemp"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>

-------------------------------------------------------------------------------------
Code behind:

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int index = GridView1.EditIndex;
        GridViewRow row = GridView1.Rows[index];
        refreshRowUpdating();
        TextBox temp1 = (TextBox)row.FindControl("tb1");
        TextBox temp2 = (TextBox)row.FindControl("tb2");
        TextBox temp3 = (TextBox)row.FindControl("tbTemp");
        temp3.Text = Convert.ToString(Convert.ToInt32(temp1.Text) + Convert.ToInt32(temp2.Text));
        Response.Write(temp3.Text);
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.