Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDataGrid Footer problem Pin
rakeshs31217-Mar-09 0:26
rakeshs31217-Mar-09 0:26 
AnswerRe: DataGrid Footer problem Pin
sunit_8217-Mar-09 2:59
sunit_8217-Mar-09 2:59 
QuestionRegarding FildUpload control Pin
ven32116-Mar-09 23:57
ven32116-Mar-09 23:57 
AnswerRe: Regarding FildUpload control Pin
venu65617-Mar-09 2:05
venu65617-Mar-09 2:05 
QuestionDoubt? Pin
Karthick_gc16-Mar-09 23:39
Karthick_gc16-Mar-09 23:39 
AnswerRe: Doubt? Pin
Colin Angus Mackay17-Mar-09 0:52
Colin Angus Mackay17-Mar-09 0:52 
QuestionConsuming XML WebService using JQuery in ASP.net 2.0 Pin
dews turner16-Mar-09 22:55
dews turner16-Mar-09 22:55 
QuestionUpdating the quantity if already exists...... Pin
RajpootRohan16-Mar-09 22:08
professionalRajpootRohan16-Mar-09 22:08 
Hi to all,

I am working on a shopping cart project. Now there is a situation that whenever adds the same product again and again, only quantity should be updated instead of adding a new everytime. I unable to do this. I tried like this.

1        protected void Page_Load(object sender, EventArgs e)
2        {
3            try
4            {
5                HyperLink HLink = (HyperLink)Master.FindControl("HyperLink3");
6                if (HLink != null)
7                {
8                    HLink.Enabled = false;
9                }
10   
11   
12               if (!Page.IsPostBack)
13               {
14                   if (Session["Cart"] == null)
15                   {
16                       Lblmsg.Visible = true;
17                       dt = new DataTable();
18                       dt.Columns.Add("REF", typeof(string));
19                       dt.Columns.Add("Description", typeof(string));
20                       dt.Columns.Add("QTY", typeof(int));
21                       dt.Columns.Add("Price", typeof(float));
22                       dt.Columns.Add("Cost", typeof(float));
23                       get_data();
24                       Session["Cart"] = dt;
25                   }
26                   else
27                   {
28                       Lblmsg.Visible = false;
29                       dt = (DataTable)Session["Cart"];
30                       get_data();
31                       update_for_same();
32                       Session["Cart"] = dt;
33                   }
34               }
35           }
36           catch(Exception ee)
37           {
38               Lblmsg.Text = ee.Message;
39           }
40       }
41   
42       public void get_data()
43       {
44           try
45           {
46               pro_id = Request.QueryString["pr_id"];
47               quanti = Convert.ToInt32(Request.QueryString["quant"]);
48   
49               if (pro_id != null)
50               {
51                   SqlConnection con = new SqlConnection("Server=.; Database=eclsc; Trusted_Connection=yes");
52                   SqlCommand cmd = new SqlCommand();
53                   cmd.Connection = con;
54                   cmd.CommandText = "select ICEMACHINES.product_id,ICEMACHINES.sh_desc,ICEMACHINES.price from ICEMACHINES where ICEMACHINES.product_id LIKE @product_id union select GLASSWARE.product_id,GLASSWARE.sh_desc,GLASSWARE.price from GLASSWARE where GLASSWARE.product_id LIKE @product_id ";
55                   cmd.Parameters.Add("@product_id", SqlDbType.NVarChar, 50).Value = pro_id;
56                   cmd.Connection.Open();
57                   SqlDataReader rdr = cmd.ExecuteReader();
58                   ArrayList arRole1 = new ArrayList();
59   
60                   while (rdr.Read())
61                   {
62                       desc = (rdr["sh_desc"]).ToString();
63                       id = (rdr["product_id"]).ToString();
64                       unitprice = Convert.ToSingle((rdr["price"]));
65                       cost = unitprice * quanti;
66   
67                   }
68                   cmd.Connection.Close();
69   
70                   DataRow myrow = dt.NewRow();
71                   myrow["REF"] = id;
72                   myrow["Description"] = desc;
73                   myrow["QTY"] = quanti;
74                   myrow["Price"] = unitprice;
75                   myrow["Cost"] = cost;
76   
77                   dt.Rows.Add(myrow);
78                   dt.AcceptChanges();
79                   Session["data"] = dt;
80                   GridView1.DataSource = dt;
81                   GridView1.DataBind();
82                   
83   
84               }
85               else
86               {
87                   int a = 1;
88               }
89               total_items = total_items + quanti;
90               total_Price = total_Price + cost;
91               Session["items"] = total_items;
92               Session["value"] = total_Price;
93           }
94           catch(Exception ee)
95           {
96               Lblmsg.Text = ee.Message;
97           }
98           }
99   
100      public void update_for_same()
101      {
102          try
103          {
104              foreach (GridViewRow rowItem in GridView1.Rows)
105              {
106                  count = GridView1.Rows.Count;
107                  //id_last = GridView1.DataKeys[count - 1].Value.ToString();
108                  index = rowItem.RowIndex;
109                  //Label lblProduct_Id = (Label)rowItem.FindControl("lblProduct_Id");
110                  id3 = GridView1.DataKeys[index].Value.ToString();
111                  //id3 = lblProduct_Id.Text;
112  
113                  TextBox TxtQTY = (TextBox)rowItem.Cells[2].FindControl("TxtQTY");
114                  Txt2 = Convert.ToInt32(TxtQTY.Text);
115              }
116          }
117          catch(Exception ee)
118          {
119              Lblmsg.Text = ee.Message;
120          }
121      }



But I dont know how to do this. Please assist me.

cheers,
sneha

AnswerRe: Updating the quantity if already exists...... Pin
N a v a n e e t h16-Mar-09 22:41
N a v a n e e t h16-Mar-09 22:41 
GeneralRe: Updating the quantity if already exists...... Pin
RajpootRohan16-Mar-09 23:10
professionalRajpootRohan16-Mar-09 23:10 
GeneralRe: Updating the quantity if already exists...... Pin
venu65617-Mar-09 1:59
venu65617-Mar-09 1:59 
GeneralRe: Updating the quantity if already exists...... Pin
RajpootRohan17-Mar-09 2:23
professionalRajpootRohan17-Mar-09 2:23 
GeneralRe: Updating the quantity if already exists...... Pin
venu65617-Mar-09 2:44
venu65617-Mar-09 2:44 
GeneralRe: Updating the quantity if already exists...... Pin
RajpootRohan17-Mar-09 18:24
professionalRajpootRohan17-Mar-09 18:24 
GeneralRe: Updating the quantity if already exists...... Pin
venu65617-Mar-09 19:47
venu65617-Mar-09 19:47 
GeneralRe: Updating the quantity if already exists...... Pin
RajpootRohan17-Mar-09 19:57
professionalRajpootRohan17-Mar-09 19:57 
GeneralRe: Updating the quantity if already exists...... Pin
venu65617-Mar-09 21:27
venu65617-Mar-09 21:27 
QuestionCould not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
Mangal Verma16-Mar-09 21:52
Mangal Verma16-Mar-09 21:52 
AnswerRe: Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
Vimalsoft(Pty) Ltd16-Mar-09 21:57
professionalVimalsoft(Pty) Ltd16-Mar-09 21:57 
GeneralRe: Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
Mangal Verma16-Mar-09 22:10
Mangal Verma16-Mar-09 22:10 
GeneralRe: Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
Vimalsoft(Pty) Ltd16-Mar-09 22:31
professionalVimalsoft(Pty) Ltd16-Mar-09 22:31 
GeneralRe: Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
Mangal Verma16-Mar-09 23:19
Mangal Verma16-Mar-09 23:19 
AnswerRe: Could not load file or assembly 'App_Code' or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0x80070070) Pin
N a v a n e e t h16-Mar-09 22:44
N a v a n e e t h16-Mar-09 22:44 
QuestionRun a .exe file that resides in cilent directory from server using VB.net Pin
yoshikev16-Mar-09 21:40
yoshikev16-Mar-09 21:40 
AnswerRe: Run a .exe file that resides in cilent directory from server using VB.net Pin
Christian Graus16-Mar-09 21:45
protectorChristian Graus16-Mar-09 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.