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
128 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
  • 2
  • 2
6 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 100 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

792 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