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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now