<asp:DataList ID="DataList1" runat="server" RepeatColumns="2" OnItemCommand="dl_item_command" RepeatDirection="Horizontal" > <ItemTemplate> <table id="Table1" cellpadding="1" cellspacing="1" visible ="true"> <tr> <td width="140px"> <p align="left"> <b>Product ID: </b> <asp:Label ID="lblEmpCode" runat ="server" Text= '<%#DataBinder.Eval(Container.DataItem, "product_id")%>'> </asp:Label> </p> </td> </tr> </table> <table id="Table2" style=" margin-top:-33px" cellpadding="1" cellspacing="1" visible ="true"> <tr> <td> <td style="left:0px"width="200px"> <p align="left"> <b>Product Name: </b> <asp:Label ID="lblEmpName" runat = "server" Text=' <%# DataBinder.Eval(Container.DataItem, "product_name")%>'> </asp:Label> </p> </td> </tr> </table> <table id="Table6" cellpadding="1" style=" margin-top:-39px" cellspacing="1" width="360px" visible ="true"> <tr> <td > <p align="left"> <asp:TextBox ID="AddToCartTB" runat = "server" Text='1' Width="44px"> </asp:TextBox> <asp:Button ID="AddToCart" runat = "server" Text='Add to Cart' Width="100px" commandname="myevent"> </asp:Button> </p> </td> </tr> </table> </ItemTemplate> </asp:DataList>
private void AddNewRow() { int rowIndex = 0; if (ViewState["CurrentTable"] != null) { DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { TextBox TB_Productid = (TextBox)grvcart.Rows[rowIndex].Cells[2].FindControl("TBProductId"); TextBox TB_ProductName = (TextBox)grvcart.Rows[rowIndex].Cells[3].FindControl("TBProductName"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["RowNumber"] = i + 1; dtCurrentTable.Rows[i - 1]["Col1"] = TB_Productid.Text; dtCurrentTable.Rows[i - 1]["Col2"] = TB_ProductName.Text; rowIndex++; } dtCurrentTable.Rows.Add(drCurrentRow); ViewState["CurrentTable"] = dtCurrentTable; grvcart.DataSource = dtCurrentTable; grvcart.DataBind(); } } else { Response.Write("ViewState is null"); } SetPreviousData(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)