Link to home
Start Free TrialLog in
Avatar of array12
array12

asked on

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

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());
            }
        }
SOLUTION
Avatar of Kamal Khaleefa
Kamal Khaleefa
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of array12
array12

ASKER

I've requested that this question be deleted for the following reason:

I solved this problem by my self.
my suggestion help you to create your code

i deserve the points