---------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="laps.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="dllap" runat="server" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black">
<AlternatingItemStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<ItemTemplate>
<table>
<tr>
<td>
<asp:CheckBox ID="chklap" runat="server" />
</td>
<asp:Label ID="lbllapid" runat="server" Text='<%#bind("lapid") %>' Visible="false"></asp:Label>
<td>
<asp:Label ID="lbllapname" runat="server" Text='<%#bind("lapname") %>'></asp:Label>
</td>
<td>
<asp:Image ID="lapimg" runat="server" ImageUrl='<%#bind("lapimg") %>' Height="100px" />
</td>
<td>
<asp:Label ID="lbllapprice" runat="server" Text='<%#bind("lapprice") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SelectedItemStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
</asp:DataList>
<asp:Button ID="btnok" runat="server" Text="ok" OnClick="btnok_Click" />
<asp:Button ID="btnlogout" runat="server" Text="logout"
onclick="btnlogout_Click" />
</div>
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------
laps.ASPX.CS
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 _Default : System.Web.UI.Page
{
Class1 obj = new Class1();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Label lbll=(Label)dl.FindControl("lbllapid");
dllap.DataSource = obj.totaaps();
dllap.DataBind();
//Session.Clear();
}
}
protected void btnok_Click(object sender, EventArgs e)
{
foreach (DataListItem dll in dllap.Items)
{
//finding the control in container.
CheckBox chk = (CheckBox)dll.FindControl("chklap");
if (chk.Checked)
{
Label lbll = (Label)dll.FindControl("lbllapid");
Label lblitemname = (Label)dll.FindControl("lbllapname");
Image lblimg = (Image)dll.FindControl("lapimg");
Label lblprice = (Label)dll.FindControl("lbllapprice");
//DataSet ds = obj.nnn(Convert.ToInt32(lbll.Text));
DataTable dt = new DataTable();
dt.Columns.Add("lapid", typeof(string));
dt.Columns.Add("lapname", typeof(string));
dt.Columns.Add("lapimg", typeof(string));
dt.Columns.Add("lapprice", typeof(string));
dt.Columns.Add("txtqty", typeof(string));
dt.Columns.Add("txtlaptotal", typeof(string));
if (Session["dt"] == null)
{
dt.Rows.Add(lbll.Text,lblitemname.Text, lblimg.ImageUrl,lblprice.Text,"","");
Session["dt"] = dt;
}
else
{
DataTable dttt = (DataTable)Session["dt"];
dttt.Rows.Add(lbll.Text, lblitemname.Text, lblimg.ImageUrl, lblprice.Text,"","");
Session["dt"] = dttt;
}
}
}
//foreach (DataListItem dl in dllap.Items)
//{
// CheckBox chk = (CheckBox)dl.FindControl("chklap");
// if (chk.Checked)
// {
// Label lbl_id = (Label)dl.FindControl("lbllapid");
// Label lbl_name = (Label)dl.FindControl("lbllapname");
// Image img = (Image)dl.FindControl("lapimg");
// Label lbl_price = (Label)dl.FindControl("lbllapprice");
// dt.Rows.Add(lbl_id.Text, lbl_name.Text, img.ImageUrl, lbl_price.Text);
// }
// Session["lapid"] = dt;
//}
Response.Redirect("selectedlap.aspx");
}
protected void btnlogout_Click(object sender, EventArgs e)
{
Session.Clear();
}
}
----------------------------------------------------------------------------------------------
Selected ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="selectedlap.aspx.cs" Inherits="selectedlap" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnlogout" runat="server" Text="Logout" onclick="btnlogout_Click" />
<asp:GridView ID="gridlap" runat="server" AutoGenerateColumns="False"
OnSelectedIndexChanged="txtqtyChange" BackColor="#DEBA84" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
<Columns>
<asp:TemplateField HeaderText="id">
<ItemTemplate>
<asp:Label ID="lbllapid" runat="server" Text='<%#bind("lapid") %>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="name">
<ItemTemplate>
<asp:Label ID="lbllapname" runat="server" Text='<%#bind("lapname") %>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="image" ControlStyle-Height="50px" ControlStyle-Width="50px">
<ItemTemplate>
<asp:Image ID="lapimg" runat="server" ImageUrl='<%#bind("lapimg") %>' />
</ItemTemplate>
<ControlStyle Height="50px" Width="50px"></ControlStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="quantity">
<ItemTemplate>
<asp:TextBox ID="txtqty" runat="server" Text='<%#Bind("txtqty") %>' OnTextChanged="txtqtyChange" AutoPostBack="true"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="price">
<ItemTemplate>
<asp:Label ID="lbllapprice" runat="server" Text='<% #bind("lapprice")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="total">
<ItemTemplate>
<asp:TextBox ID="txtlaptotal" runat="server" Text='<%#Bind("txtlaptotal") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
total:
<asp:TextBox ID="totaltxt" runat="server"></asp:TextBox>
<asp:Button ID="btnbacklap" runat="server" Text="back"
OnClick="btnbacklap_Click" style="height: 26px" />
</div>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------
selected.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class selectedlap : System.Web.UI.Page
{
Class1 obj1 = new Class1();
int total = 0;
DataTable dt2;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dtr = (DataTable)Session["dt"];
gridlap.DataSource = dtr;
gridlap.DataBind();
}
}
public void txtqtyChange(object sender, EventArgs e)
{
foreach (GridViewRow gd in gridlap.Rows)
{
TextBox txttotal = (TextBox)gd.FindControl("txtlaptotal");
TextBox txt = (TextBox)gd.FindControl("txtqty");
Label lbl = (Label)gd.FindControl("lbllapprice");
if (txt.Text == string.Empty)
{
}
else
{
txttotal.Text = Convert.ToString(Convert.ToInt32(txt.Text) * Convert.ToDecimal(lbl.Text));
total += Convert.ToInt32(txttotal.Text);
}
}
totaltxt.Text = total.ToString();
}
protected void btnbacklap_Click(object sender, EventArgs e)
{
Session.Clear();
foreach (GridViewRow objrow in gridlap.Rows)
{
Label lblid = (Label)objrow.FindControl("lbllapid");
Label lbname = (Label)objrow.FindControl("lbllapname");
Image img = (Image)objrow.FindControl("lapimg");
TextBox txtqtyy = (TextBox)objrow.FindControl("txtqty");
Label lblprice = (Label)objrow.FindControl("lbllapprice");
TextBox txttotl = (TextBox)objrow.FindControl("txtlaptotal");
if (Session["dt"] != null)
{
DataTable dt1 = (DataTable)Session["dt"];
dt1.Rows.Add(lblid.Text, lbname.Text, img.ImageUrl, lblprice.Text,txtqtyy.Text, txttotl.Text);
Session["dt"] = dt1;
}
else
{
DataTable dt = new DataTable();
dt.Columns.Add("lapid", typeof(string));
dt.Columns.Add("lapname", typeof(string));
dt.Columns.Add("lapimg", typeof(string));
dt.Columns.Add("lapprice", typeof(string));
dt.Columns.Add("txtqty", typeof(string));
dt.Columns.Add("txtlaptotal", typeof(string));
dt.Rows.Add(lblid.Text, lbname.Text, img.ImageUrl, lblprice.Text, txtqtyy.Text, txttotl.Text);
Session["dt"] = dt;
}
}
Response.Redirect("laps.aspx");
}
// Response.Redirect("laps.aspx");
protected void btnlogout_Click(object sender, EventArgs e)
{
Session.Clear();
}
}
----------------------------------------------------------------------------------------------------
.Class.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public string cn = ConfigurationManager.ConnectionStrings["con"].ToString();
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter da;
DataSet ds;
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public DataSet totaaps()
{
con = new SqlConnection(cn);
cmd = new SqlCommand("select * from lap", con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
public DataSet nnn(int lapid)
{
con = new SqlConnection(cn);
cmd = new SqlCommand("select * from lap where lapid='"+lapid+"'", con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
}
---------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
public string cn = ConfigurationManager.ConnectionStrings["con"].ToString();
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter da;
DataSet ds;
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public DataSet totaaps()
{
con = new SqlConnection(cn);
cmd = new SqlCommand("select * from lap", con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
public DataSet nnn(int lapid)
{
con = new SqlConnection(cn);
cmd = new SqlCommand("select * from lap where lapid='"+lapid+"'", con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
}
---------------------------------------------------------------------------------------------------