<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="Productid" HeaderText="Product Id" InsertVisible="False" ReadOnly="True" SortExpression="Productid" HeaderStyle-Width="90px" ItemStyle-HorizontalAlign="Center"/> <asp:BoundField DataField="Pname" HeaderText="Product Name" SortExpression="Pname" HeaderStyle-Width="300px" ItemStyle-HorizontalAlign="Center"/> <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="Center"/> <asp:TemplateField HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="80px"><ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text="1" Width="20px" AutoPostBack="true"></asp:TextBox></ItemTemplate></asp:TemplateField> <asp:TemplateField HeaderText="Total Price" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px"> <ItemTemplate><asp:Label ID="Label1" runat="server"></asp:Label></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView><br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBCS %>"> </asp:SqlDataSource>
Public Partial Class WebForm5 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Session("usertype") = "User" Then SqlDataSource1.SelectCommand = "SELECT Productid, Pname, Price FROM Stock WHERE Productid IN (SELECT Productid FROM Cart WHERE Userid='" & Session("userid").ToString & "' AND Datetoday='" & Date.Today & "' AND Payment='No')" Else Response.Redirect("Account.aspx") End If End Sub Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim cellquantity As TableCell = e.Row.Cells(3) Dim tb As TextBox = CType(cellquantity.FindControl("TextBox1"), TextBox) Dim celltotalprice As TableCell = e.Row.Cells(4) Dim lbl As Label = CType(celltotalprice.FindControl("Label1"), Label) lbl.Text = Convert.ToString(Convert.ToInt32(e.Row.Cells(2).Text) * Convert.ToInt32(tb.Text)) End If End Sub End Class
SELECT Productid, Pname, Price,quantity,(price*quantity) as Total FROM Stock
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)