Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiply the gridview columns
    primarykey
    data
    text
    <p>I will post you my code and i will explain what i want to do</p> <pre><code>&lt;div&gt; &lt;div&gt; &lt;asp:GridView ID="gridView1" runat="server"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="chkSelect" runat="server" /&gt; &lt;asp:HiddenField ID="hdValue" runat="server" Value='&lt;%#Eval("ID") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;div&gt; &lt;asp:Button ID="btnMove" runat="server" Text="Add To Cart" OnClick="btnMove_Click" /&gt; &lt;/div&gt; &lt;div&gt; &lt;asp:GridView ID="gridView2" runat="server"&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Quantity"&gt; &lt;ItemTemplate&gt; &lt;asp:TextBox ID="tbQty" runat="server" Width="25px" MaxLength="3" /&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width="25px" HorizontalAlign="Center"/&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;br /&gt; &lt;asp:Button ID="Button1" runat="server" Text="Find the total" /&gt; &lt;asp:Label ID="Label7" runat="server" Text="Total"&gt;&lt;/asp:Label&gt; &lt;asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; &lt;br /&gt; &lt;/div&gt; </code></pre> <p>and the theo.aspx.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class theo : System.Web.UI.Page { const string key = "MyDataSource5"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGridView(); } } private void BindGridView() { if (Session[key] == null) { gridView1.DataSource = GetDataSource(); gridView1.DataBind(); } else { gridView1.DataSource = (DataTable)Session[key]; gridView1.DataBind(); } } protected DataTable GetDataSource() { try { DataTable dt = new DataTable(); dt = new DataTable(); dt.Columns.Add("ID", typeof(int)).AutoIncrement = true; dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Price(Grouch)/Hectares", typeof(float)); DataColumn[] keys = new DataColumn[2]; keys[0] = dt.Columns["ID"]; dt.PrimaryKey = keys; dt.Rows.Add("1", "Seaside Location", 1.5); dt.Rows.Add("2", "Arable Land", 0.1); dt.Rows.Add("3", "Foothills of the mountains", 1.5); dt.Rows.Add("4", "Industrial Land", 0.1); dt.Rows.Add("5", "Rolling Farmland", 0.5); Session[key] = dt; return dt; } catch { return null; } } protected void btnMove_Click(object sender, EventArgs e) { try { DataTable dtMain = Session[key] as DataTable; //copy the schema of source table DataTable dtClone = dtMain.Clone(); foreach (GridViewRow gv in gridView1.Rows) { CheckBox chk = gv.FindControl("chkSelect") as CheckBox; HiddenField hdValue = gv.FindControl("hdValue") as HiddenField; if (chk.Checked) { //get only the rows you want DataRow[] results = dtMain.Select("ID=" + hdValue.Value + ""); //populate new destination table foreach (DataRow dr in results) { dtClone.ImportRow(dr); } } gridView2.DataSource = dtClone; gridView2.DataBind(); } } catch { BindGridView(); } } } </code></pre> <p>In this code when i check for example 2 choices from gridview 1 and click the button add to cart then these 2 choices are moving to the second gridview. As you see,I have a textbox for the quantity. I would like when i give the quantity to multiply it with the price.With the button 'find the total' i want to give me the result in the text box.How can i do that?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload