Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

To retain value from postback event

Posted on 2009-05-02
45
Medium Priority
?
1,320 Views
Last Modified: 2013-12-17
In my defaul.asp.cs :
I define public boolean variable (DialcodeSelected, countryselected), when user selects option from dropdown list, I can set their value to true. However when I start processing these values even I set it true, but Its value is still false

Thx,
JT
   
0
Comment
Question by:jtran007
  • 22
  • 20
42 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 24295716
The page, with all its variables, is created anew on each postback.

If you want to keep values between postbacks, you can assign the values to your Session state (Session["variablename"] = true)
or if you do not want to maintain session state you can maintain the values in a hidden field inside the page.
0
 

Author Comment

by:jtran007
ID: 24301035
Hi Expert,

After setting value for this var, how can I use it? I try to use if (Session["variable"] == 1), the compiler
complains.

Thx,
JT
0
 
LVL 23

Assisted Solution

by:Jens Fiederer
Jens Fiederer earned 2000 total points
ID: 24301623
Not surprising - you can put ANYTHING inside a session variable, so the compiler has no way of knowing that you decided to stick an int in there.

You can do
    (int)Session["variable"]) ==  1
or (perhaps better)
    Session["variable"].ToString() == "1"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jtran007
ID: 24304881
Hi expert,

Since I save in the objec declared as Report: I can use:

            Report = (ReportTypeClass)Session["Report"];
I got the value right; however, when selecting option in the list box, I try to
make some control visible. It's working under visual studio IDE, but when I
run in the local host http://myip/default.aspx it's not working. I don't know why.
could you help?
Thx,
JT
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24304958
What's going wrong?
0
 

Author Comment

by:jtran007
ID: 24305359
I have a list box that I can value whose value is saved in the session.
Depending on the value, I can turn a label ON or OFF.
In visual IDE, I change value, it show label fine.
It is not working if I run in the browser since my app is
web app.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24305386
WHAT is happening when you run in the browser?
0
 

Author Comment

by:jtran007
ID: 24305404
I select the option in the list box which seems not working in browser: label is not shown whereas
under visual studio the label is shown.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24305413
Please post your code.
0
 

Author Comment

by:jtran007
ID: 24305590
Yes. I attach her
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Configuration;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
 
namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        ReportTypeClass Report;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            Trace.Write("Loading page...XT");
            txtDialCode.Dispose();
            if (!IsPostBack)
            {
                Report = new ReportTypeClass();
                Session["Report"] = Report;
            }
            else
            {
                Report = (ReportTypeClass)Session["Report"];
            }
        }
 
        protected void Button1_Click1(object sender, EventArgs e)
        {
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            Trace.Write("Clicking Calendar...XT");
        }
 
 
        protected void Button1_Click2(object sender, EventArgs e)
        {
            Trace.Write("Clicking Load me...XT");
 
 
            if (Report.Country)
            {
                DisplayCountry();
            }
            else if (Report.Dialcode)
            {
                DisplayDialcode();
 
            }
 
        }
 
 
        protected void radReportTypeList_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
 
        protected void grdStatReport_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
 
        protected void DisplayCountry()
        {
            Response.Write("I am in the country ...");
            //
            //  Get report selection 
            //
            //int dialCodeTxt;
            string TableName = "Processdialcode";
            string sqlConnect = "datasource=172.16.10.252;userid=root;password=abc;database=statdb;port=3307";
            MySqlConnection connection = new MySqlConnection(sqlConnect);
            connection.Open();
            //
            // Select country name
            //
 
            ListItem item = this.lstCountry.Items[lstCountry.SelectedIndex];
            string countryName = item.ToString();
            //
            // Find the first word
            //
            string[] wordsPeriod = countryName.Split('.');
            string[] wordsSpace = countryName.Split(' ');
            string[] wordsSlash = countryName.Split('/');
            string firstWord = null;
            bool   specialName = false;
            if (wordsPeriod.Length > 1)  
            {
                 firstWord = wordsPeriod[0];
                 specialName = true;
            }
            else if ( wordsSlash.Length > 1)
            {
                firstWord = wordsSlash[0];
                specialName = true;
            }
            else if (wordsSpace.Length > 1)
            {
                firstWord = wordsSpace[0];
                specialName = true;
            }
 
 
 
            //
            // Create temp new table for processing statistical data
            //
            string sqlCreate0 = "Create temporary table if not exists " + TableName + " as select idcode,dialcode,name,rate,callsall,calls1s,calls30s," +
                                  "dura1s,dura30s,asrall,asr30s,acd from carrier_rate where ";
 
            //string sqlCreate = sqlCreate0 + " name like " + "\'" + countryName + "%\'";
               string sqlCreate;
            if ( specialName) 
                sqlCreate = sqlCreate0 + " name like " + "\'" + firstWord + "%\'";
            else
                sqlCreate = sqlCreate0 + " name like " + "\'" + countryName + "%\'";
 
            MySqlCommand command = new MySqlCommand(sqlCreate, connection);
            MySqlDataReader dataReader = command.ExecuteReader();
 
            dataReader.Close();
            //if (this.DialCodeSelected== true)
            //
            // now get number of records to reserve maximum records for the distint dialcode 
            //
            string sqlGetNoRecords = "select count(*) from " + TableName;
            MySqlCommand commandGetNoRecords = new MySqlCommand(sqlGetNoRecords, connection);
            MySqlDataReader myReader0 = commandGetNoRecords.ExecuteReader();
            int NumRecords = 0;
 
            while (myReader0.Read())
            {
                NumRecords = myReader0.GetInt32(0);
            }
            myReader0.Close();
            //
            // Find distint dialcode
            //
            //string sqlGetDistint = "select count(*),name from " + TableName + " where name like " + "\'" + countryName + "%\' group by dialcode";
             string sqlGetDistint;
            if (specialName)
                    sqlGetDistint = "select count(*),name from " + TableName + " where name like " + "\'" + firstWord + "%\'group by name";
            else
                    sqlGetDistint = "select count(*),name from " + TableName + " where name like " + "\'" + countryName + "%\'group by name";
 
            MySqlCommand cmdGetNoDistint = new MySqlCommand(sqlGetDistint, connection);
            MySqlDataReader myRdDistint = cmdGetNoDistint.ExecuteReader();
 
            string[] noCountries = new string[NumRecords];
            int[] noRecords = new int[NumRecords];
            int noDistintCountries = 0;
 
            while (myRdDistint.Read())
            {
                noRecords[noDistintCountries] = myRdDistint.GetInt16(0);
                noCountries[noDistintCountries] = myRdDistint.GetString(1);
                noDistintCountries++;
            }
            myRdDistint.Close();
 
            ListItem item2 = drpAnalysis.Items[drpAnalysis.SelectedIndex];
            string reportType = item2.ToString();
 
 
            //
            //  For each dialcode, search each idcode for
            //  the ordered type report requested.
            //
            DataSet ds = new DataSet();
            ds.Tables.Add("Report");
            ds.Tables["Report"].Columns.Add("Country");
            ds.Tables["Report"].Columns.Add("DialCode");
            ds.Tables["Report"].Columns.Add("Name");
            ds.Tables["Report"].Columns.Add("FirstCarrier");
            ds.Tables["Report"].Columns.Add("1stRate");
 
            ds.Tables["Report"].Columns.Add("Second");
            ds.Tables["Report"].Columns.Add("2ndRate");
 
            ds.Tables["Report"].Columns.Add("Third");
            ds.Tables["Report"].Columns.Add("3rdRate");
 
            ds.Tables["Report"].Columns.Add("Fourth");
            ds.Tables["Report"].Columns.Add("4thRate");
 
            ds.Tables["Report"].Columns.Add("Highest");
            ds.Tables["Report"].Columns.Add("HiRate");
            ds.Tables["Report"].Columns.Add("Lowest");
            ds.Tables["Report"].Columns.Add("LoRate");
            ds.Tables["Report"].Columns.Add("Mean");
            this.grdStatReport.DataSource = null;
            this.grdStatReport.DataBind();
 
            //string sqlFinalData1 = sqlGetData2 + noCountries[ind].ToString() + "%' and " + "  rate > 0 order by ";
            //string sqlFinalData = sqlFinalData1  + " rate DESC limit 4";
 
 
            //string reportType = radReportTypeList.SelectedItem.Text;
            string sqlGetData2 = null;
            //if (specialName[)
               sqlGetData2 = "select " + reportType + " , name, idcode, rate from " + TableName + " where name like ' ";
            //else
 
            for (int ind = 0; ind < noDistintCountries; ind++)
            {
                string sqlFinalData1 = sqlGetData2 + noCountries[ind].ToString() + "%' and " + reportType + " > 0 order by ";
                string sqlFinalData = sqlFinalData1 + reportType + " DESC limit 4";
                MySqlCommand commandProcess3 = new MySqlCommand(sqlFinalData, connection);
                MySqlDataReader myReader3 = commandProcess3.ExecuteReader();
 
                //
                // Save the 1rst,2nd,3rd, and 4th type rate to array for display.
                //
                double[] rateType = new double[4];  // Only the first, second, third, and fourth is cared.
                string[] carrier_name = new string[4];
                int[] idcode = new int[4];
                double[] carrier_rate = new double[4];
                int index = 0;
                while (myReader3.Read())
                {
                    if (reportType.Equals("Callsall")
                        || reportType.Equals("Calls1s")
                        || reportType.Equals("Calls30s")
                        || reportType.Equals("Dura1s")
                        || reportType.Equals("Dura30s"))
                    {
                        rateType[index] = myReader3.GetInt32(0);
                        if (rateType[index] == 0)
                            break;
                    }
                    else
                    {
                        rateType[index] = myReader3.GetDouble(0);
                        if (rateType[index] == 0.0)
                            break;
                    }
 
                    carrier_name[index] = myReader3.GetString(1);
                    idcode[index] = myReader3.GetUInt16(2);
                    carrier_rate[index] = myReader3.GetDouble(3);
                    index++;
 
                }
                myReader3.Close();
                //
                // Search table carrier_info_a1 for the company name
                // with the same idcode in the carrier_rate table
                //
 
                string[] CompanyName = new string[4];
 
                string sqlFindCompanyName1 = "select CompanyName from carrier_info_a1 where IDcode= ";
                for (int m = 0; m < 4; m++)
                {
 
                    string sqlFindCompanyName = sqlFindCompanyName1 + idcode[m].ToString();
                    MySqlCommand sqlFindCoCommand = new MySqlCommand(sqlFindCompanyName, connection);
                    MySqlDataReader FindCoRd = sqlFindCoCommand.ExecuteReader();
                    while (FindCoRd.Read())
                        CompanyName[m] = FindCoRd.GetString(0);
 
                    FindCoRd.Close();
                }
                //
                // Eliminate duplicate company  
                //
                for (int j = 0; j < 3; j++)
                {
                    if (CompanyName[j] != null)
                    {
                        //temp = CompanyName[j];
                        for (int k = j + 1; k < 4; k++)
                        {
                            if ((CompanyName[j] != null) && (CompanyName[k] != null) && (j != k))
                            {
                                if (CompanyName[j].Equals(CompanyName[k]))
                                {
                                    // CompanyName2[k] = CompanyName[j];
                                    carrier_rate[k] = 0.0;
                                    CompanyName[k] = null;
 
                                }
                            }
                        }
                    }
                }
                //
                // Find average rate
                //
                double Average = 0.0;
                int noValid = 0;
 
                for (int n = 0; n < 4; n++)
                {
                    if (carrier_rate[n] > 0) noValid++;
                    Average = Average + carrier_rate[n];
                }
                Average /= noValid;
 
                //                                        
                // Now binding these data info to the gridview
                // if data is > 0
                //
 
 
                double max = carrier_rate.Max();
                //double min = carrier_rate.Min();
 
                if ((max == 0.0)) continue;
 
                //
                //
                string strMax = null;
                string strMin = null;
 
                //
                // Find max company
                //
                for (int i = 0; i < 4; i++)
                {
 
                    if (carrier_rate[i] == max && max > 0)
                    {
                        for (int ind2 = 0; ind2 < 4; ind2++)
                        {
                            if (idcode[ind2] == idcode[i])
                            {
                                strMax = CompanyName[ind2];
                                goto found_max; // found the first max quickly corresponding with higher ratetypr
                                //break;
                            }
                        }
                    }
                }
            //
            // find the lowest != 0
            //
            found_max:
                double lowest = 0.0;
                double[] tmpRate = new double[4];
                tmpRate = carrier_rate;
 
 
                for (int i = 0; i < 3; i++)
                {
                    for (int j = i + 1; j < 4; j++)
                    {
                        if ((tmpRate[i] > tmpRate[j]) && tmpRate[i] > 0 & tmpRate[j] > 0)
                        {
                            lowest = tmpRate[j];
                            tmpRate[j] = tmpRate[i];
                            tmpRate[i] = lowest;
 
                        }
                    }
                }
                double min = tmpRate[0];
 
                //
                // get company name
                //
                for (int j5 = 0; j5 < 4; j5++)
                {
                    if (carrier_rate[j5] == min && min > 0)
                    {
                        for (int ind2 = 0; ind2 < 4; ind2++)
                        {
                            if (idcode[ind2] == idcode[j5])
                            {
                                strMin = CompanyName[ind2];
                                goto found_min;   // found the first min quickly corresponding with higher ratetypr
                            }
                        }
 
                    }
 
 
                }
            found_min:
                if (rateType[0] > 0)
                {
                    DataRow rowNew = ds.Tables["Report"].NewRow();
                    rowNew["Country"] = noCountries[ind];
                    //rowNew["DialCode"] = noDialcode[ind];
                    rowNew["Name"] = carrier_name[0];
                    // rowNew["Rate"] = carrier_rate[0];
 
                    rowNew["FirstCarrier"] = CompanyName[0];
                    rowNew["1stRate"] = carrier_rate[0];
 
                    rowNew["Second"] = CompanyName[1];
                    rowNew["2ndRate"] = carrier_rate[1];
 
                    rowNew["Third"] = CompanyName[2];
                    rowNew["3rdRate"] = carrier_rate[2];
 
                    rowNew["Fourth"] = CompanyName[3];
                    rowNew["4thRate"] = carrier_rate[3];
 
                    rowNew["Highest"] = strMax;
                    rowNew["HiRate"] = max;
 
                    rowNew["Lowest"] = strMin;
                    rowNew["LoRate"] = min;
 
                    rowNew["Mean"] = Average;
 
                    ds.Tables["Report"].Rows.Add(rowNew);
                }
            }
            grdStatReport.DataSource = ds.Tables["Report"];
            grdStatReport.DataBind();
 
            connection.Close();
        }
 
        protected void DisplayDialcode()
        {
            //
            //  Get report selection 
            //
            int dialCodeTxt;
            string TableName = "Processdialcode";
            string sqlConnect = "datasource=172.16.10.252;userid=root;password=abc;database=statdb;port=3307";
            MySqlConnection connection = new MySqlConnection(sqlConnect);
            connection.Open();
            //
            // Create temp new table for processing statistical data
            //
            string sqlCreate0 = "Create temporary table if not exists " + TableName + " as select idcode,dialcode,name,rate,callsall,calls1s,calls30s," +
                                  "dura1s,dura30s,asrall,asr30s,acd from carrier_rate where ";
 
            //if (this.DialCodeSelected== true)
            //{
 
            dialCodeTxt = Int32.Parse(txtDialCode.Text);
            string sqlCreate = sqlCreate0 + " dialcode like " + "\'" + dialCodeTxt.ToString() + "%\'";
            MySqlCommand command = new MySqlCommand(sqlCreate, connection);
            MySqlDataReader dataReader = command.ExecuteReader();
 
            dataReader.Close();
 
            //
            // now get number of records to reserve maximum records for the distint dialcode 
            //
            string sqlGetNoRecords = "select count(*) from " + TableName;
            MySqlCommand commandGetNoRecords = new MySqlCommand(sqlGetNoRecords, connection);
            MySqlDataReader myReader0 = commandGetNoRecords.ExecuteReader();
            int NumRecords = 0;
 
            while (myReader0.Read())
            {
                NumRecords = myReader0.GetInt32(0);
            }
            myReader0.Close();
            //
            // Find distint dialcode
            //
            string sqlGetDistint = "select count(*),dialcode from " + TableName + " where dialcode like " + "\'" + dialCodeTxt.ToString() + "%\' group by dialcode";
            MySqlCommand cmdGetNoDistint = new MySqlCommand(sqlGetDistint, connection);
            MySqlDataReader myRdDistint = cmdGetNoDistint.ExecuteReader();
 
            int[] noDialcode = new int[NumRecords];
            int[] noRecords = new int[NumRecords];
            int noDistintDialcode = 0;
 
            while (myRdDistint.Read())
            {
                noRecords[noDistintDialcode] = myRdDistint.GetInt16(0);
                noDialcode[noDistintDialcode] = myRdDistint.GetInt32(1);
                noDistintDialcode++;
            }
            myRdDistint.Close();
 
            ListItem item2 = drpAnalysis.Items[drpAnalysis.SelectedIndex];
            string reportType = item2.ToString();
 
 
            //
            //  For each dialcode, search each idcode for
            //  the ordered type report requested.
            //
            DataSet ds = new DataSet();
            ds.Tables.Add("Report");
            ds.Tables["Report"].Columns.Add("DialCode");
            ds.Tables["Report"].Columns.Add("Name");
            //ds.Tables["Report"].Columns.Add("Rate");
            ds.Tables["Report"].Columns.Add("FirstCarrier");
            ds.Tables["Report"].Columns.Add("1stRate");
 
            ds.Tables["Report"].Columns.Add("Second");
            ds.Tables["Report"].Columns.Add("2ndRate");
 
            ds.Tables["Report"].Columns.Add("Third");
            ds.Tables["Report"].Columns.Add("3rdRate");
 
            ds.Tables["Report"].Columns.Add("Fourth");
            ds.Tables["Report"].Columns.Add("4thRate");
 
            ds.Tables["Report"].Columns.Add("Highest");
            ds.Tables["Report"].Columns.Add("HiRate");
            ds.Tables["Report"].Columns.Add("Lowest");
            ds.Tables["Report"].Columns.Add("LoRate");
            ds.Tables["Report"].Columns.Add("Mean");
            this.grdStatReport.DataSource = null;
            this.grdStatReport.DataBind();
 
 
 
            //string reportType = radReportTypeList.SelectedItem.Text;
            string sqlGetData2 = null;
 
            sqlGetData2 = "select " + reportType + " , name, idcode, rate from " + TableName + " where dialcode= ";
 
 
 
            for (int ind = 0; ind < noDistintDialcode; ind++)
            {
                string sqlFinalData1 = sqlGetData2 + noDialcode[ind].ToString() + " and " + reportType + " > 0 " + " order by ";
                string sqlFinalData = sqlFinalData1 + reportType + " DESC limit 4";
                MySqlCommand commandProcess3 = new MySqlCommand(sqlFinalData, connection);
                MySqlDataReader myReader3 = commandProcess3.ExecuteReader();
 
                //
                // Save the 1rst,2nd,3rd, and 4th type rate to array for display.
                //
                double[] rateType = new double[4];  // Only the first, second, third, and fourth is cared.
                string[] carrier_name = new string[4];
                int[] idcode = new int[4];
                double[] carrier_rate = new double[4];
                int index = 0;
                while (myReader3.Read())
                {
                    if (reportType.Equals("Callsall")
                        || reportType.Equals("Calls1s")
                        || reportType.Equals("Calls30s")
                        || reportType.Equals("Dura1s")
                        || reportType.Equals("Dura30s"))
                    {
                        rateType[index] = myReader3.GetInt32(0);
                        if (rateType[index] == 0)
                            break;
                    }
                    else
                    {
                        rateType[index] = myReader3.GetDouble(0);
                        if (rateType[index] == 0.0)
                            break;
                    }
 
                    carrier_name[index] = myReader3.GetString(1);
                    idcode[index] = myReader3.GetUInt16(2);
                    carrier_rate[index] = myReader3.GetDouble(3);
                    index++;
 
                }
                myReader3.Close();
                //
                // Search table carrier_info_a1 for the company name
                // with the same idcode in the carrier_rate table
                //
 
                string[] CompanyName = new string[4];
 
                string sqlFindCompanyName1 = "select CompanyName from carrier_info_a1 where IDcode= ";
                for (int m = 0; m < 4; m++)
                {
 
                    string sqlFindCompanyName = sqlFindCompanyName1 + idcode[m].ToString();
                    MySqlCommand sqlFindCoCommand = new MySqlCommand(sqlFindCompanyName, connection);
                    MySqlDataReader FindCoRd = sqlFindCoCommand.ExecuteReader();
                    while (FindCoRd.Read())
                        CompanyName[m] = FindCoRd.GetString(0);
 
                    FindCoRd.Close();
                }
                //
                // Make sure item is unique
                //
 
                //string temp ;
                //string[] CompanyName2 = new string[4];
 
                for (int j = 0; j < 3; j++)
                {
                    if (CompanyName[j] != null)
                    {
                        //temp = CompanyName[j];
                        for (int k = j+1; k < 4; k++)
                        {
                            if ((CompanyName[j] != null) && (CompanyName[k] != null) && (j != k))
                            {
                                if (CompanyName[j].Equals(CompanyName[k]))
                                {
                                    // CompanyName2[k] = CompanyName[j];
                                    carrier_rate[k] = 0.0;
                                    CompanyName[k] = null;
 
                                }
                            }
                        }
                    }
                }
 
 
                //
                // Find average rate
                //
                double Average = 0.0;
                int noValid = 0;
 
                for (int n = 0; n < 4; n++)
                {
                    if (carrier_rate[n] > 0) noValid++;
                    Average = Average + carrier_rate[n];
                }
                Average /= noValid;
 
                //                                        
                // Now binding these data info to the gridview
                // if data is > 0
                //
 
 
                double max = carrier_rate.Max();
                //double min = carrier_rate.Min();
 
                if ((max == 0.0)) continue;
 
                //
                //
                string strMax = null;
                string strMin = null;
 
                //
                // Find max company
                //
                for (int i = 0; i < 4; i++)
                {
 
                    if (carrier_rate[i] == max && max > 0)
                    {
                        for (int ind2 = 0; ind2 < 4; ind2++)
                        {
                            if (idcode[ind2] == idcode[i])
                            {
                                strMax = CompanyName[ind2];
                                goto found_max; // found the first max quickly corresponding with higher ratetypr
                                //break;
                            }
                        }
                    }
                }
            //
            // find the lowest != 0
            //
            found_max:
                double lowest = 0.0;
                double[] tmpRate = new double[4];
                tmpRate = carrier_rate;
 
 
                for (int i = 0; i < 3; i++)
                {
                    for (int j = i + 1; j < 4; j++)
                    {
                        if ((tmpRate[i] > tmpRate[j]) && tmpRate[i] > 0 & tmpRate[j] > 0)
                        {
                            lowest = tmpRate[j];
                            tmpRate[j] = tmpRate[i];
                            tmpRate[i] = lowest;
 
                        }
                    }
                }
                double min = tmpRate[0];
 
                //
                // get company name
                //
                for (int j5 = 0; j5 < 4; j5++)
                {
                    if (carrier_rate[j5] == min && min > 0)
                    {
                        for (int ind2 = 0; ind2 < 4; ind2++)
                        {
                            if (idcode[ind2] == idcode[j5])
                            {
                                strMin = CompanyName[ind2];
                                goto found_min;   // found the first min quickly corresponding with higher ratetypr
                            }
                        }
 
                    }
 
 
                }
            found_min:
                if (rateType[0] > 0)
                {
 
                    DataRow rowNew = ds.Tables["Report"].NewRow();
                    rowNew["DialCode"] = noDialcode[ind];
                    rowNew["Name"] = carrier_name[0];
                    // rowNew["Rate"] = carrier_rate[0];
 
                    rowNew["FirstCarrier"] = CompanyName[0];
                    rowNew["1stRate"] = carrier_rate[0];
 
                    rowNew["Second"] = CompanyName[1];
                    rowNew["2ndRate"] = carrier_rate[1];
 
                    rowNew["Third"] = CompanyName[2];
                    rowNew["3rdRate"] = carrier_rate[2];
 
                    rowNew["Fourth"] = CompanyName[3];
                    rowNew["4thRate"] = carrier_rate[3];
 
                    rowNew["Highest"] = strMax;
                    rowNew["HiRate"] = max;
 
                    rowNew["Lowest"] = strMin;
                    rowNew["LoRate"] = min;
 
                    rowNew["Mean"] = Average;
 
                    ds.Tables["Report"].Rows.Add(rowNew);
                }
 
            }
 
            grdStatReport.DataSource = ds.Tables["Report"];
            grdStatReport.DataBind();
 
            connection.Close();
        }
 
 
 
        protected void lstReportType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListItem item = lstReportType.Items[lstReportType.SelectedIndex];
            string Type = item.ToString();
            if (Type.Equals("Dialcode"))
            {
                txtDialCode.Enabled = true;
                txtDialCode.Visible = true;
                Label1.Visible = true;
                Report.Dialcode = true;
                Report.Country = false;
//                grdStatReport.DataSource = null;
//                grdStatReport.DataBind();
                Label2.Visible = false;
                lstCountry.Enabled = false;
                lstCountry.Visible = false;
                Report.Dialcode = true;
                Report.Country = false;
 
            }
            else if (Type.Equals("Country"))
            {
                lstCountry.Enabled = true;
                lstCountry.Visible = true;
                Label2.Visible = true;
                Report.Country = true;
                Report.Dialcode = false;
 
 //               grdStatReport.DataSource = null;
 //               grdStatReport.DataBind();
                Label1.Visible = false;
                txtDialCode.Enabled = false;
                txtDialCode.Visible = false;
                Report.Country = true;
                Report.Dialcode = false;
            }
            RefreshDisplay();
 
        }
 
 
        protected void grdStatReport_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.grdStatReport.PageIndex = e.NewPageIndex;
            this.grdStatReport.DataBind();
        }
 
        protected void btnDownloadAll_Click(object sender, EventArgs e)
        {
            grdStatReport.AllowPaging = false;
            grdStatReport.DataBind();
 
            Response.ClearContent();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            //DateTime now = new DateTime;
            //string date = now.Date();
 
            Response.AddHeader("content-disposition", "attachment;filename=yyyymmdd.xls");
            //string attachment = "attachment; filename=reports.xls";
            //Response.AddHeader("content-disposition", attachment);
            //Response.ContentType = "application/ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
 
            // Create a form to contain the grid
            HtmlForm frm = new HtmlForm();
            this.grdStatReport.Parent.Controls.Add(frm);
            frm.Attributes["runat"] = "server";
            frm.Controls.Add(grdStatReport);
 
            frm.RenderControl(htw);
            //GridView1.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();
 
 
        }
 
        protected void grdStatReport_PageIndexChanged(object sender, EventArgs e)
        {
 
        }
 
        protected void btnViewA1Report_Click(object sender, EventArgs e)
        {
            grdStatReport.Dispose();
 
            if (Report.Country)
                DisplayA1Country();
            else if (Report.Dialcode)
                DisplayA1Dialcode();
 
        }
 
        protected void DisplayA1Country()
        {
           //{
        }
 
        protected void DisplayA1Dialcode()
        {
            //
            //  Get report selection 
            //
            int dialCodeTxt;
            string TableName = "Processdialcode";
            string sqlConnect = "datasource=172.16.10.252;userid=root;password=abc;database=statdb;port=3307";
            MySqlConnection connection = new MySqlConnection(sqlConnect);
            connection.Open();
            //
            // Create temp new table for processing statistical data
            //
            string sqlCreate0 = "Create temporary table if not exists " + TableName + " as select idcode,dialcode,name,rate,callsall,calls1s,calls30s," +
                                  "dura1s,dura30s,asrall,asr30s,acd from carrier_rate where ";
            dialCodeTxt = Int32.Parse(txtDialCode.Text);
            string sqlCreate = sqlCreate0 + " dialcode like " + "\'" + dialCodeTxt.ToString() + "%\'";
            MySqlCommand command = new MySqlCommand(sqlCreate, connection);
            MySqlDataReader dataReader = command.ExecuteReader();
            dataReader.Close();
            string sqlGetNoRecords = "select count(*) from " + TableName;
            MySqlCommand commandGetNoRecords = new MySqlCommand(sqlGetNoRecords, connection);
            MySqlDataReader myReader0 = commandGetNoRecords.ExecuteReader();
            int NumRecords = 0;
 
            while (myReader0.Read())
            {
                NumRecords = myReader0.GetInt32(0);
            }
            myReader0.Close();
            //
            // Find distint dialcode
            //
            string sqlGetDistint = "select count(*),dialcode from " + TableName + " where dialcode like " + "\'" + dialCodeTxt.ToString() + "%\' group by dialcode";
            MySqlCommand cmdGetNoDistint = new MySqlCommand(sqlGetDistint, connection);
            MySqlDataReader myRdDistint = cmdGetNoDistint.ExecuteReader();
 
            int[] noDialcode = new int[NumRecords];
            int[] noRecords = new int[NumRecords];
            int noDistintDialcode = 0;
 
            while (myRdDistint.Read())
            {
                noRecords[noDistintDialcode] = myRdDistint.GetInt16(0);
                noDialcode[noDistintDialcode] = myRdDistint.GetInt32(1);
                noDistintDialcode++;
            }
            myRdDistint.Close();
            //
            // Now find the company name for these idcodes
            //
            string sqlFindIdcode = "select idcode from carrier_rate where dialcode = " + dialCodeTxt.ToString();
            MySqlCommand cmdIdcode = new MySqlCommand(sqlFindIdcode, connection);
            MySqlDataReader RdIdcode = cmdIdcode.ExecuteReader();
            int[] noIdcode = new int[NumRecords];
            int k1 = 0;
            while (RdIdcode.Read())
                noIdcode[k1++] = RdIdcode.GetInt16(0);
            RdIdcode.Close();
            //
            // Company name
            //
            string[] CompanyName = new string[NumRecords];
 
            for (int i2 = 0; i2 < k1; i2++)
            {
                string sqlDistintCompa = "select companyname from carrier_info_a1 where idcode= " + noIdcode[i2].ToString();
                MySqlCommand cmdCompa = new MySqlCommand(sqlDistintCompa, connection);
                MySqlDataReader RdCompa = cmdCompa.ExecuteReader();
                int i3 = 0;
                while (RdCompa.Read())
                    CompanyName[i3++] = RdCompa.GetString(0);
                RdCompa.Close();
            }
 
            DataSet ds = new DataSet();
            ds.Tables.Add("Report");
            ds.Tables["Report"].Columns.Add("DialCode");
            ds.Tables["Report"].Columns.Add("Name");
            //ds.Tables["Report"].Columns.Add("Rate");
            ds.Tables["Report"].Columns.Add("Company");
            ds.Tables["Report"].Columns.Add("Rate");
 
            ds.Tables["Report"].Columns.Add("CallsAll");
            ds.Tables["Report"].Columns.Add("Calls1S");
 
            ds.Tables["Report"].Columns.Add("Calls30S");
            ds.Tables["Report"].Columns.Add("Dura1S");
 
            ds.Tables["Report"].Columns.Add("Dura30S");
            ds.Tables["Report"].Columns.Add("AsrAll");
 
            ds.Tables["Report"].Columns.Add("Asr30S");
            ds.Tables["Report"].Columns.Add("ACD");
            this.grdStatReport.DataSource = null;
            this.grdStatReport.DataBind();
            //string sqlGetData2 = null;
 
            // sqlGetData2 = "select " + reportType + " , name, idcode, rate from " + TableName + " where dialcode= ";
            //
            // Now prepare records for reporting
            //
            for (int ind = 0; ind < noDistintDialcode; ind++)
            {
                string sqlGetA1Records0 = "select dialcode,name,rate,callsall,calls1s,calls30s,dura1s,dura30s,asrall,asr30s,acd from carrier_rate where dialcode= ";
                //string sqlGetA1Records0 = "select * from carrier_rate where dialcode= ";
                string sqlGetA1Records = sqlGetA1Records0 + dialCodeTxt.ToString();
                MySqlCommand cmdA1Records = new MySqlCommand(sqlGetA1Records, connection);
                MySqlDataReader RdA1Records = cmdA1Records.ExecuteReader();
 
                int tmpDialcode = 0;
                string tmpName = null;
                double tmpRate = 0.0;
                int tmpCallsAll = 0;
                int tmpCalls1S = 0;
                int tmpCalls30s = 0;
                int tmpDura1s = 0;
                int tmpDura30s = 0;
                double tmpAsrall = 0.0;
                double tmpAsr30s = 0.0;
                double tmpAcd = 0.0;
 
                while (RdA1Records.Read())
                {
                    tmpDialcode = RdA1Records.GetInt32(0);
                    tmpName = RdA1Records.GetString(1);
                    tmpRate = RdA1Records.GetDouble(2);
                    // string tmpComp =   CompanyName[ind];
                    tmpCallsAll = RdA1Records.GetInt16(3);
                    tmpCalls1S = RdA1Records.GetInt16(4);
                    tmpCalls30s = RdA1Records.GetInt16(5);
                    tmpDura1s = RdA1Records.GetInt16(6);
                    tmpDura30s = RdA1Records.GetInt32(7);
                    tmpAsrall = RdA1Records.GetDouble(8);
                    tmpAsr30s = RdA1Records.GetDouble(9);
                    tmpAcd = RdA1Records.GetDouble(10);
                }
                RdA1Records.Close();
                //
                // Now add new values to the tables
                //
                DataRow rowNew = ds.Tables["Report"].NewRow();
                rowNew["DialCode"] = tmpDialcode;
                rowNew["Name"] = tmpName;
                rowNew["Company"] = CompanyName[ind];
                rowNew["Rate"] = tmpRate;
                rowNew["CallsAll"] = tmpCallsAll;
                rowNew["Calls1S"] = tmpCalls1S;
                rowNew["Calls30S"] = tmpCalls30s;
                rowNew["Dura1S"] = tmpDura1s;
                rowNew["Dura30S"] = tmpDura30s;
                rowNew["AsrAll"] = tmpAsrall;
                rowNew["Asr30s"] = tmpAsr30s;
                rowNew["ACD"] = tmpAcd;
 
                ds.Tables["Report"].Rows.Add(rowNew);
            }
            grdStatReport.DataSource = ds.Tables["Report"];
            grdStatReport.DataBind();
            connection.Close();
 
        }
        private void RefreshDisplay()
        {
            ListItem item = lstReportType.Items[lstReportType.SelectedIndex];
            string Type = item.ToString();
            if (Type.Equals("Dialcode"))
            {
                txtDialCode.Enabled = true;
                txtDialCode.Visible = true;
                Label1.Visible = true;
                Report.Dialcode = true;
                Report.Country = false;
                //                grdStatReport.DataSource = null;
                //                grdStatReport.DataBind();
                Label2.Visible = false;
                lstCountry.Enabled = false;
                lstCountry.Visible = false;
                Report.Dialcode = true;
                Report.Country = false;
 
            }
            else if (Type.Equals("Country"))
            {
                lstCountry.Enabled = true;
                lstCountry.Visible = true;
                Label2.Visible = true;
                Report.Country = true;
                Report.Dialcode = false;
 
                //               grdStatReport.DataSource = null;
                //               grdStatReport.DataBind();
                Label1.Visible = false;
                txtDialCode.Enabled = false;
                txtDialCode.Visible = false;
                Report.Country = true;
                Report.Dialcode = false;
            }
    
 }
 
        protected void lstReportType_Load(object sender, EventArgs e)
        {
            ListItem item = lstReportType.Items[lstReportType.SelectedIndex];
            string Type = item.ToString();
            if (Type.Equals("Dialcode"))
            {
                txtDialCode.Enabled = true;
                txtDialCode.Visible = true;
                Label1.Visible = true;
                Report.Dialcode = true;
                Report.Country = false;
                //                grdStatReport.DataSource = null;
                //                grdStatReport.DataBind();
                Label2.Visible = false;
                lstCountry.Enabled = false;
                lstCountry.Visible = false;
                Report.Dialcode = true;
                Report.Country = false;
 
            }
            else if (Type.Equals("Country"))
            {
                lstCountry.Enabled = true;
                lstCountry.Visible = true;
                Label2.Visible = true;
                Report.Country = true;
                Report.Dialcode = false;
 
                //               grdStatReport.DataSource = null;
                //               grdStatReport.DataBind();
                Label1.Visible = false;
                txtDialCode.Enabled = false;
                txtDialCode.Visible = false;
                Report.Country = true;
                Report.Dialcode = false;
            }
 
        }
    }
}

Open in new window

0
 

Author Comment

by:jtran007
ID: 24305601
This is a class definition
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace WebApplication1
{
    public class ReportTypeClass
    {
        private bool dialcode;
 
        public bool Dialcode
        {
            get { return dialcode; }
            set { dialcode = value; }
        }
        private bool country;
 
        public bool Country
        {
            get { return country; }
            set { country = value; }
        }
        public ReportTypeClass()
        {
            dialcode = false;
            Country = false;
 
        }
    }
}

Open in new window

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24305608
The aspx, too, please.
0
 

Author Comment

by:jtran007
ID: 24305727
Here it is.
Thx,
JT
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dialcode.aspx.cs" Inherits="WebApplication1._Default" Trace="false" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <style type="text/css">
        #form1
        {
            height: 94px;
            width: 1024px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 23px; width: 855px">
    
    </div>
    <asp:Panel ID="Panel1" runat="server" Height="138px" Width="1006px" 
        BackColor="#E9E9E9">
        <asp:Label ID="Label4" runat="server" Text="ReportType"></asp:Label>
        <asp:DropDownList ID="lstReportType" runat="server" BackColor="#FFFFCC" 
            Height="25px" onselectedindexchanged="lstReportType_SelectedIndexChanged" 
            Width="146px" AutoPostBack="True" onload="lstReportType_Load">
             <asp:ListItem>Dialcode</asp:ListItem>
           <asp:ListItem>Country</asp:ListItem>
        </asp:DropDownList>
        <asp:Label ID="Label1" runat="server" Text="DialCode" Visible="False"></asp:Label>
        <asp:TextBox ID="txtDialCode" runat="server" Width="142px" BackColor="#FFFFCC" 
            Enabled="False" Visible="False"></asp:TextBox>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:statdbConnectionString3 %>" 
            ProviderName="<%$ ConnectionStrings:statdbConnectionString3.ProviderName %>" 
            SelectCommand="select country from country"></asp:SqlDataSource>
        <asp:Label ID="Label2" runat="server" Text="Country" Visible="False"></asp:Label>
        <asp:ListBox ID="lstCountry" runat="server" DataSourceID="SqlDataSource1" 
            DataTextField="country" DataValueField="country" Height="67px" 
            style="margin-top: 1px" Width="166px" BackColor="#FFFFCC" Enabled="False" 
            Visible="False"></asp:ListBox>
        <asp:Label ID="Label3" runat="server" Text="Analysis Type"></asp:Label>
        <asp:DropDownList ID="drpAnalysis" runat="server" Height="31px" 
            style="margin-top: 0px" Width="142px" BackColor="#FFFFCC">
            <asp:ListItem>CallsAll</asp:ListItem>
            <asp:ListItem>Calls1S</asp:ListItem>
            <asp:ListItem>Calls30S</asp:ListItem>
            <asp:ListItem>Dura1S</asp:ListItem>
            <asp:ListItem>Dura30S</asp:ListItem>
            <asp:ListItem>AsrAll</asp:ListItem>
            <asp:ListItem>Asr30S</asp:ListItem>
            <asp:ListItem>ACD</asp:ListItem>
            <asp:ListItem>A1Report</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click2" 
            Text="Show Report" Width="112px" />
        
        <asp:Button ID="btnDownLoad" runat="server" Height="27px" Text="DownLoad" 
            Width="102px" />
        <asp:Button ID="btnDownloadAll" runat="server" Height="26px" 
            style="margin-top: 0px" Text="ExportToExcelAll" Width="109px" 
            onclick="btnDownloadAll_Click" />
        <asp:Button ID="btnViewA1Report" runat="server" onclick="btnViewA1Report_Click" 
            Text="ViewA1Report" />
        <br />
        <br />
        <asp:Panel ID="Panel2" runat="server" BackColor="Red" Height="16px" 
            Width="1007px">
        </asp:Panel>
        
    </asp:Panel>
    
    <!Sql source>
    
     <asp:GridView ID="grdStatReport" runat="server" CellPadding="4" 
        ForeColor="#333333" Height="324px" Width="1005px" style="margin-top: 112px" 
        AllowPaging="True" 
        EnableSortingAndPagingCallbacks="True" 
        onselectedindexchanged="grdStatReport_SelectedIndexChanged" 
        onpageindexchanged="grdStatReport_PageIndexChanged" 
        onpageindexchanging="grdStatReport_PageIndexChanging">
              <PagerSettings Position="TopAndBottom" />
              <RowStyle BackColor="#E3EAEB" />
              <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
              <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
              <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
              <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
              <EditRowStyle BackColor="#7C6F57" />
              <AlternatingRowStyle BackColor="White" />
              
    </asp:GridView>
       
 
    
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:jtran007
ID: 24305782
Also my gridview seems not working eventhough I set allowpaging is true, and handle event for
pagechaging. Do you know why?

Thx,
JT
0
 

Author Comment

by:jtran007
ID: 24306105
I increase this point.
0
 
LVL 23

Assisted Solution

by:Jens Fiederer
Jens Fiederer earned 2000 total points
ID: 24307882
Well, at least I can help you with the latter part:
grdStatReport_PageIndexChanged is never being called because you promised to handle that on the client with EnableSortingAndPagingCallbacks - you don't need that to be true.

Also, your event has to RESET the datasource before doing the databind.
An easy way for that is to do
Session["ds"] =  ds.Tables["Report"];
when you first create the report and then
        this.grdStatReport.PageIndex = e.NewPageIndex;
        grdStatReport.DataSource = Session["ds"];
        this.grdStatReport.DataBind();
when you change pages.

For the question about the label, which of the labels do you mean?
0
 

Author Comment

by:jtran007
ID: 24310582
Hi expert,

I mean the dialcode label, and the country list box. Depeding on the selection of
report type list box, I can turn these control ON or OFF.

Thx,
JT
0
 

Author Comment

by:jtran007
ID: 24310608
Hi expert,

The way you describe how to change page is that all?
I read some book, the author mentions about the pageindex,
and calculate how many pages, ...
Since my computer at work can run my program, not the one at home.
I'll try your recommendation tomorrow.
Thx,
JT
0
 

Author Comment

by:jtran007
ID: 24314047
I got the error. Attached is the message

 Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.InvalidOperationException: Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.
 
Source Error:
 
Line 1207:
Line 1208:            //grdStatReport.DataSource = GetDataPage(grdStatReport.PageIndex, grdStatReport.PageSize);
Line 1209:            grdStatReport.DataSource = Session["Report"];
Line 1210:            grdStatReport.DataBind();
Line 1211:        }
 
 
Source File: C:\Develop\qiiq\projects\WebApplication2\WebApplication1\Dialcode.aspx.cs    Line: 1209
 
Stack Trace:
 
[InvalidOperationException: Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.]
   System.Web.UI.WebControls.DataBoundControl.ValidateDataSource(Object dataSource) +1626762
   System.Web.UI.WebControls.BaseDataBoundControl.set_DataSource(Object value) +24
   WebApplication1._Default.grdStatReport_PageIndexChanging(Object sender, GridViewPageEventArgs e) in C:\Develop\qiiq\projects\WebApplication2\WebApplication1\Dialcode.aspx.cs:1209
   System.Web.UI.WebControls.GridView.OnPageIndexChanging(GridViewPageEventArgs e) +133
   System.Web.UI.WebControls.GridView.HandlePage(Int32 newPage) +86
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +464
   System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207
   System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
 
 
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 

Open in new window

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24314101
The code where you SET the Datasource looks OK....where do you set Session["Report"]?
0
 
LVL 23

Assisted Solution

by:Jens Fiederer
Jens Fiederer earned 2000 total points
ID: 24314180
Oh - as the "dialcode label, and the country list box" go, when I run it on my computer, those successfully change depending on the setting of the "report type" drop down.  Of course, it works for YOU, too, when you are in the development environment.

To diagnose what is happening there, I would add some tracing - make sure that "lstReportType_SelectedIndexChanged" is being fired on your server, and that it completes successfully.  My suspicion would be that there is something wrong with your database setup and some exception is being thrown that you are not noticing that stops the change from completing.
0
 

Author Comment

by:jtran007
ID: 24315059
Hi expert,

1- You are right. it's working now in the visual development but not in the browse. do you know why?
I move this Session["ds"] =  ds.Tables["Report"] to where I create ds.

2-lstReportType_SelectedIndexChanged event is fired. Again it's working under visual development but not in Browser.

Could you help?
Thx,
JT
0
 

Author Comment

by:jtran007
ID: 24315065
How can I test under browser?
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24315099
1 - If you did
    Session["ds"] =  ds.Tables["Report"]
you must do
    grdStatReport.DataSource = Session["ds"];
instead of
    grdStatReport.DataSource = Session["Report"];

2 - Are you saying it is NOT firing in the Browser?  If not, is there anything else unusual happening in the browser, any exceptions being thrown?  Is other database data displaying?
0
 

Author Comment

by:jtran007
ID: 24315523
You are right . Infact I did grdStatReport.DataSource = Session["ds"];
Now I test it under firefox browser . It's working but not Microsoft explorer.

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24315605
Everything works the way you want it in Firefox?
0
 

Author Comment

by:jtran007
ID: 24316191
Yes. do you know to change ms explorer?
0
 
LVL 23

Assisted Solution

by:Jens Fiederer
Jens Fiederer earned 2000 total points
ID: 24316441
You might want to use a tool such as the IE Developer Toolbar ( http://en.wikipedia.org/wiki/IE_Developer_Toolbar ) to see what is going on in the IE world - it will let you look at what is being posted to the browser.
0
 

Author Comment

by:jtran007
ID: 24319531
Hi expert,

How can I export portion or all of gridview to excel file?

Thx,
JT
0
 
LVL 23

Assisted Solution

by:Jens Fiederer
Jens Fiederer earned 2000 total points
ID: 24319601
Often cut and paste will work pretty well.  There are also methods such as http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html

But we are really going far from the original question about values disappearing - you should only ask ONE question in a question.
0
 

Author Comment

by:jtran007
ID: 24321858
Thanks,
JT
0
 

Author Comment

by:jtran007
ID: 24321862
Thx,
JT
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24323012
Unbelievable.  Ask as many questions as you can on a single question, then request deletion.
0
 

Author Comment

by:jtran007
ID: 24327090
Hi expert,

I am sorry. Last night I tried to close the case, and award your points. But somehow at the
end it ask me comment. I did but it still asking me . That's why I somehow I close the [X] window.
I don't mean to insult you. I think it's mistake.
I' d like to close and award your points.
Thx,
JT
0
 

Author Comment

by:jtran007
ID: 24327156
Thanks a lot
JT
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24327170
Sorry - it just seemed very strange when you sent "thank you" messages and then requested deletion.

The inteface is not always easy to use....and I don't have any questions of my OWN open to test, but I think you need to pick one of the comments and use it as the answer (the first one is really the most germane to the original question, so if somebody else is searching on it, that one should be used).

The comment is just to say something additional, it is not necessary to fill it in.

0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24327192
Apparently the author is having a difficult time using the interface.  

His intention is clear, hopefully a moderator will help out with this.
0
 

Author Comment

by:jtran007
ID: 24328203
I understand now.
Thx,
JT
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24328993
Then I definitely apologize for my negative reaction - but that suggests there is something messed up with EE, because I definitely received a message that the question was going to be DELETED.

If you look at
http://www.experts-exchange.com/Community_Support/General/Q_24387821.html?cid=239#a24328872

it says "An objection was posted which cancelled the automated process of deleting the question.  The objection is as follows:"


So if there was at no point an attempt to delete this question, why was there an "automated process of deleting the question?"
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24329078
OK, correction,....the message I received did not say it would be DELETED, just CLOSED (with no mention of my solution being accepted).  This is the text I retrieved, not normally what I get when somebody accepts my solution:

A question you participated in will be closed in four days:
Hello, jensfiederer!
A question you participated in will be closed in four days:
Question: To retain value from postba...
Zone: C# Programming Language
Reason: The expert solves my question.
Thx,
JT
jtran007 has requested that this question be closed. If you object to this action, you have four days to post a comment describing your objection. This will generate a request in Community Support for Moderator review. If no Expert objects, this question will be closed as described above.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24330079
Yes, I saw that in the link I sent you (which I didn't get myself until well after the original message that got to me "jtran007 has requested that this question be closed. If you object to this action, you have four days to post a comment describing your objection."

#1 Why in the world would I want to object to being awarded the points?  Odd message, and I've never gotten one of those before when one of my answers was accepted.

#2 Why does http://www.experts-exchange.com/Community_Support/General/Q_24387821.html?cid=239#a24328872 talk about deleting the question?
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 24330113
Thanks for settling this, JT, and sorry again for reacting harshly.

My guess is the system got confused about having the points split between so many answers.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

810 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