protected void Grid_Purchase_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TextBox txtqty = e.Row.FindControl("txt_grd_qty") as TextBox; TextBox txtprice = e.Row.FindControl("txt_grd_piece_amt") as TextBox; TextBox txtAmount = e.Row.FindControl("txt_grd_amt") as TextBox; txtqty.Attributes["onKeyup"] = "javascript: return GetTotal('" + Convert.ToInt32(txtqty.Text) + "','" + Convert.ToInt32(txtprice.Text) + "','" + Convert.ToInt32(txtAmount.ClientID) + "')";//Here i got the error as input string is not in corect format txtprice.Attributes["onKeyup"] = "javascript: return GetTotal('" + Convert.ToInt32(txtqty.Text) + "','" + Convert.ToInt32(txtprice.Text) + "','" + Convert.ToInt32(txtAmount.ClientID) + "')"; } }
<script type="text/javascript"> function GetTotal(Qty, Rate, txt3) { document.getElementById(txt3).value=Qty*Rate; } </script>
<asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:TextBox ID="txt_grd_qty" Width="75px" runat="server"></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <FooterTemplate> <asp:TextBox ID="Foot_Txt4" runat="server" Width="75px"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Piece/Amt"> <ItemTemplate> <asp:TextBox ID="txt_grd_piece_amt" Width="75px" runat="server" AutoPostBack="true" ></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <FooterTemplate> <asp:TextBox ID="Foot_Txt5" runat="server" Width="75px"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Amount"> <ItemTemplate> <asp:TextBox ID="txt_grd_amt" runat="server" Width="75px" Enabled="false" ></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <FooterTemplate> <asp:TextBox ID="Foot_Txt6" runat="server" Width="75px"></asp:TextBox> </FooterTemplate> </asp:TemplateField>
Convert.ToInt32(txtAmount.ClientID)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)