Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I have two pages main page have grid view it works fine the second page is redirect result from main page that is also work fine, but when calculate sum of selected row it does not show to the redirec

Posted on 2015-02-06
6
Medium Priority
?
139 Views
Last Modified: 2015-02-21
Here is the code from main page:
 private void SendGridInfo()
        {
           

            DataTable dt = new DataTable();
            DataRow dr = default(DataRow);
           
            dt.Columns.Add(new System.Data.DataColumn("Invoice Number", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("Original Amount", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("Remaining Amount", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("Amount To Pay", typeof(string)));

            foreach (GridViewRow row in GridView2.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk = (CheckBox)row.FindControl("chkSelect");
                    Label label0 = (Label)row.FindControl("Label0") as Label;
                    Label label3 = row.FindControl("Label3") as Label;
                    Label label4 = (Label)row.FindControl("Label4") as Label;
                    TextBox textbox1 = (TextBox)row.FindControl("txtRemainingAmount") as TextBox;

                    if (chk.Checked)
                    {
                        dr = dt.NewRow();
                        dr[0] = label0.Text;
                        dr[1] = label3.Text;
                        dr[2] = label4.Text;
                        dr[3] = textbox1.Text;
                        dt.Rows.Add(dr);
                    }
                }
            }
           
            Session["GridData"] = dt;
            RedirectTo("Selected Invoice");
        }
the redirected page code is:
 protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["GridData"] != null)
            {
                //Response.Write(Session["lblTotal.Text"].ToString());
                DataTable dt = (DataTable)Session["GridData"];
                GridView2.DataSource = dt;
                GridView2.DataBind();
                Response.Write(Session["GridData"].ToString());
            }
        }
0
Comment
Question by:array12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 400 total points
ID: 40602918
you need to make a for loop on you datatable and loop for each row and add sum all the values
then you can show it on the page
0
 

Accepted Solution

by:
array12 earned 0 total points
ID: 40603459
I did this,
for(int I =0; I<GridView2.Rows.Count-1; I++)
{
    CheckBox chkb = GridView2.Rows[i].FindControl("chkSelect") as CheckBox;
          if (chkb.Checked == true)
           {
                sum+=textbox1.text
           }
txttotal.text=sum.ToString();
}
but no luck

Open in new window

0
 

Author Comment

by:array12
ID: 40613542
I've requested that this question be deleted for the following reason:

I solved this problem by my self.
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 40610657
my suggestion help you to create your code

i deserve the points
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question