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

ASP.NET

 
GeneralRe: SelectedItem Problem in ASP.Net Pin
Arun Jacob15-Sep-09 19:03
Arun Jacob15-Sep-09 19:03 
GeneralRe: SelectedItem Problem in ASP.Net Pin
Shalini_U16-Sep-09 3:04
Shalini_U16-Sep-09 3:04 
AnswerRe: SelectedItem Problem in ASP.Net Pin
Arun Jacob16-Sep-09 18:31
Arun Jacob16-Sep-09 18:31 
AnswerRe: SelectedItem Problem in ASP.Net Pin
Arun Jacob17-Sep-09 18:09
Arun Jacob17-Sep-09 18:09 
QuestionIncreasing the Size of the webpage Pin
.NET- India 15-Sep-09 3:11
.NET- India 15-Sep-09 3:11 
AnswerRe: Increasing the Size of the webpage Pin
Manas Bhardwaj15-Sep-09 3:23
professionalManas Bhardwaj15-Sep-09 3:23 
AnswerRe: Increasing the Size of the webpage Pin
Abhishek Sur15-Sep-09 6:50
professionalAbhishek Sur15-Sep-09 6:50 
Questiongridview delete row event firing twice? Pin
compninja2515-Sep-09 3:09
compninja2515-Sep-09 3:09 
Hi Everyone,

I've setup a simple shopping application and have created a shopping cart using a session DataTable. I've added a delete button column to my grid and then supplied code to remove the indexed row when someone clicks the button. What's weird, is I keep receiving an error indicating that the selected row index does not exist! when I place a debug on my code, it appears as though the logic is working correctly, but right after the row is deleted, it fires the page_onload event, works through all that logic (which reloads the new updated datatable), and then tries to delete the row again.

Here's my page_onLoad:

protected void Page_Load(object sender, EventArgs e)
       {
           double est_ship = 100.00;
           //try to load the cart from session memory. hit empty cart functions if not found / empty
           try
           {
               DataTable dt1 = (DataTable)Session["myCart"];
               if (dt1.Rows.Count > 0)
               {
                   itemsGrid.DataSource = dt1;
                   itemsGrid.DataBind();
                   double subt = 0.0;
                   foreach (System.Data.DataRow row in dt1.Rows)
                   {
                       subt += Convert.ToDouble(row["LineTotal"]);
                   }
                   double tax = (subt * 0.06);
                   sub_total_lbl.Text = subt.ToString("c");
                   tax_lbl.Text = tax.ToString("c");
                   est_ship_lbl.Text = est_ship.ToString("c");
                   total_lbl.Text = (subt + tax + est_ship).ToString("c");
                   make_order_btn.Enabled = true;
               }
               else
               {
                   emptyCart();
               }
           }
           catch (NullReferenceException)
           {
               emptyCart();
           }


the emptyCart method simply set's the various labels on the page to indicate there's no items in the cart.

and here's the row_deleting event:

protected void itemsGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
       {
           DataTable dt1 = (DataTable)Session["myCart"];
           dt1.Rows.Remove(dt1.Rows[e.RowIndex]);
       }


I've been looking at the asp.net page lifecycle diagrams, but from what I've seen there it doesn't explain why the row_deleting event is being executed twice. Could it be a control issue?

Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.

AnswerRe: gridview delete row event firing twice? Pin
Greg Chelstowski15-Sep-09 3:34
Greg Chelstowski15-Sep-09 3:34 
GeneralRe: gridview delete row event firing twice? Pin
compninja2515-Sep-09 3:47
compninja2515-Sep-09 3:47 
GeneralRe: gridview delete row event firing twice? Pin
Greg Chelstowski15-Sep-09 4:29
Greg Chelstowski15-Sep-09 4:29 
GeneralRe: gridview delete row event firing twice? Pin
compninja2516-Sep-09 5:25
compninja2516-Sep-09 5:25 
Questionasp.net for loop example Pin
Member 464032615-Sep-09 3:03
Member 464032615-Sep-09 3:03 
AnswerRe: asp.net for loop example Pin
Manas Bhardwaj15-Sep-09 3:20
professionalManas Bhardwaj15-Sep-09 3:20 
GeneralRe: asp.net for loop example Pin
Member 464032615-Sep-09 3:26
Member 464032615-Sep-09 3:26 
Questioncellspacing not worked in Opera browser Pin
Jain Vijay15-Sep-09 2:15
Jain Vijay15-Sep-09 2:15 
AnswerRe: cellspacing not worked in Opera browser Pin
Abhishek Sur15-Sep-09 6:53
professionalAbhishek Sur15-Sep-09 6:53 
Questionhow to update elements in modal popup by using java script Pin
Zapss15-Sep-09 1:57
Zapss15-Sep-09 1:57 
AnswerRe: how to update elements in modal popup by using java script Pin
compninja2515-Sep-09 3:14
compninja2515-Sep-09 3:14 
GeneralRe: how to update elements in modal popup by using java script Pin
Zapss15-Sep-09 20:46
Zapss15-Sep-09 20:46 
GeneralRe: how to update elements in modal popup by using java script Pin
Zapss15-Sep-09 22:20
Zapss15-Sep-09 22:20 
GeneralRe: how to update elements in modal popup by using java script Pin
compninja2516-Sep-09 2:04
compninja2516-Sep-09 2:04 
AnswerRe: how to update elements in modal popup by using java script Pin
Abhishek Sur15-Sep-09 6:58
professionalAbhishek Sur15-Sep-09 6:58 
QuestionString Compair Pin
JAYRAJ GIRI15-Sep-09 1:44
JAYRAJ GIRI15-Sep-09 1:44 
AnswerRe: String Compair Pin
Manas Bhardwaj15-Sep-09 1:52
professionalManas Bhardwaj15-Sep-09 1:52 

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.