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
122 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

785 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