0

I load the the grid(Grid is editable), having Price-Quantity-Amount columns.
I want to change Amount when I change Quantity.I want to do it at clientside.
Any suggestions?

<asp:UpdatePanel runat="server" ID="UpdatePanel1">
   <Triggers>
   <asp:AsyncPostBackTrigger ControlID="btnOk" />
   </Triggers>
   <ContentTemplate>
   <asp:GridView ID="gdv_QuotItems" runat="server" AutoGenerateColumns="false" OnRowDataBound="gdv_QuotItems_RowDataBound"                                           EmptyDataText="No Items To Load.">
   <Columns>
<asp:TemplateField HeaderText="Price">
   <ItemTemplate>
   <asp:Label ID="Label6" Text='<%# Bind("Price") %>' runat="server" Width="100%"></asp:Label>                                                                <AJX:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="Label6"                                                      PopupControlID="popUpPanel">                                                                </AJX:ModalPopupExtender>                                                            </ItemTemplate>                                                        </asp:TemplateField>                                                        <asp:TemplateField HeaderText="Quantity">                                                            <ItemTemplate>                                                                <asp:TextBox ID="TextBox1" Text='<%# Bind("Quantity") %>' runat="server"></asp:TextBox>                                                            </ItemTemplate>                                                        </asp:TemplateField>                                                        <asp:TemplateField HeaderText="Amount">                                                            <ItemTemplate>                                                              <asp:Label ID="Label8" Text='<%# Bind("Amount") %>' runat="server" Width="100%"></asp:Label>                                                                <AJX:ModalPopupExtender ID="ModalPopupExtender8" runat="server" TargetControlID="Label8"            PopupControlID="popUpPanel">                                                    </AJX:ModalPopupExtender>
    </Columns>        
  </asp:GridView>  
 </ContentTemplate>
  </asp:UpdatePanel>                                                            </ItemTemplate>                                                        </asp:TemplateField>

Edited by Nitin Daphale: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Nitin Daphale
0

I load the the grid(Grid is editable), having Price-Quantity-Amount columns.
I want to change Amount when I change Quantity.I want to do it at clientside.
Any suggestions?

<asp:UpdatePanel runat="server" ID="UpdatePanel1">
   <Triggers>
   <asp:AsyncPostBackTrigger ControlID="btnOk" />
   </Triggers>
   <ContentTemplate>
   <asp:GridView ID="gdv_QuotItems" runat="server" AutoGenerateColumns="false" OnRowDataBound="gdv_QuotItems_RowDataBound"                                           EmptyDataText="No Items To Load.">
   <Columns>
<asp:TemplateField HeaderText="Price">
   <ItemTemplate>
   <asp:Label ID="Label6" Text='<%# Bind("Price") %>' runat="server" Width="100%"></asp:Label>                                                                <AJX:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="Label6"                                                      PopupControlID="popUpPanel">                                                                </AJX:ModalPopupExtender>                                                            </ItemTemplate>                                                        </asp:TemplateField>                                                        <asp:TemplateField HeaderText="Quantity">                                                            <ItemTemplate>                                                                <asp:TextBox ID="TextBox1" Text='<%# Bind("Quantity") %>' runat="server"></asp:TextBox>                                                            </ItemTemplate>                                                        </asp:TemplateField>                                                        <asp:TemplateField HeaderText="Amount">                                                            <ItemTemplate>                                                              <asp:Label ID="Label8" Text='<%# Bind("Amount") %>' runat="server" Width="100%"></asp:Label>                                                                <AJX:ModalPopupExtender ID="ModalPopupExtender8" runat="server" TargetControlID="Label8"            PopupControlID="popUpPanel">                                                    </AJX:ModalPopupExtender>
    </Columns>        
  </asp:GridView>  
 </ContentTemplate>
  </asp:UpdatePanel>                                                            </ItemTemplate>                                                        </asp:TemplateField>

I tried this but getting javascript error and couldn't get desired result.
Anybody if had done this kind of thing please send the code.
Thanks again in advance.

protected void gdv_QuoSundry_RowDataBound(object sender, GridViewRowEventArgs e)
    {
 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            TextBox TextBox1 = (TextBox)e.Row.FindControl("TextBox1");
            TextBox TextBox2 = (TextBox)e.Row.FindControl("TextBox2");

            if (TextBox1 == null)
            {
                TextBox2.Attributes.Add("onBlur", "changeMe('"+TextBox1.ClientID+  "','"+TextBox2.ClientID+"')");
            }

        }
}

  <script type="text/javascript">
   function changeMe(oPrice,  oSubTotal) {
            var Price = document.getElementById(oPrice).value;
           
            SubTotal = Price * 10;
            document.getElementById(oSubTotal).value = SubTotal;
        }
     </script>
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.