<asp:gridview id="Gridview1" runat="server" emptydatatext="Data is not available" onrowdatabound="Gridview1_RowDataBound" autogeneratecolumns="false"> <columns> <asp:TemplateField HeaderText="ID"> <itemtemplate> <asp:TextBox ID="txtID" runat="server" Text='<%#Eval("ID") %>' /> <asp:TemplateField HeaderText="Quantity"> <itemtemplate> <asp:TextBox ID="txtQuantity" runat="server" Text='<%#Eval("Quantity","0") %>' /> <asp:TemplateField HeaderText="Rate"> <itemtemplate> <asp:TextBox ID="txtRate" runat="server" Text='<%#Eval("Rate","0") %>' /> <asp:TemplateField HeaderText="Total"> <itemtemplate> <asp:TextBox ID="txtTotal" runat="server" Text='<%#Eval("Total","0") %>' />
protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int index=0; //if (e.Row.RowType >= null) //{ TextBox txtRate = (TextBox)Gridview1.Rows[index].Cells[1].FindControl("txtRate"); TextBox txtQuantity = (TextBox)Gridview1.Rows[index].Cells[2].FindControl("txtQuantity"); TextBox txtTotal = (TextBox)Gridview1.Rows[index].Cells[3].FindControl("Total"); int R = int.Parse(txtRate.Text); int Q = int.Parse(txtQuantity.Text); int T = int.Parse(txtTotal.Text); T = Convert.ToInt32(R * Q); txtTotal.Text = T.ToString(); //} } }
if ((e.Row.RowType == DataControlRowType.DataRow)) { TextBox txtRate = e.Row.FindControl("txtRate"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)