Link to home
Start Free TrialLog in
Avatar of codeoxygen
codeoxygen

asked on

passing dataset from one page to another

hi ,
     My task is on clicking a button all the values in the from and grid should pass to another Page. for example if click submit button in page A , all details(form and grid) form page A  should transfer to page B. here in page be i should assign these values.


My problem is in Page B grid is initialized only on row on page load. how to add rows dinamicatlly and assign the values.


Thanks in advance
Avatar of Mrunal
Mrunal
Flag of India image

Better way ideally you have to keep this data in cache/session.
Avatar of codeoxygen
codeoxygen

ASKER

my problem is not passing data ... but how to assign the values to grid manually
can you post your .aspx and .cs code here, so that we can help you in better way?

just making assumtion, if you are passing dataset from one page to another using session, you just need to create an object of dataset or datatable, cast the data from session as below.
DataSet Dt= (DataSet)session["sessiondata"];
and bind the gridview with dataset object as
gridview.datasource=dt;
gridview.databind();

hope this helps.
my problem is , i have grid view , it has add new row button.  If i want bind data from a data-set. what is the method. the scenario is, already saved grid-view data should be retrieve and even it should be editable
private void FirstGridViewRow()
        {
            DataTable dt = new DataTable();
            DataRow dr = null;
            dt.Columns.Add("RowNumber", typeof(int));
            dt.Columns["RowNumber"].AutoIncrement = true;
            dt.Columns["RowNumber"].AutoIncrementSeed = 1;
            dt.Columns["RowNumber"].AutoIncrementStep = 1;
           
            dt.Columns.Add(new DataColumn("Col2", typeof(string)));
            dt.Columns.Add(new DataColumn("Col3", typeof(string)));
            dt.Columns.Add(new DataColumn("Col4", typeof(string)));
            dt.Columns.Add(new DataColumn("Col5", typeof(string)));
            dt.Columns.Add(new DataColumn("Col6", typeof(string)));
            dt.Columns.Add(new DataColumn("Col7", typeof(string)));
            dt.Columns.Add(new DataColumn("Col8", typeof(string)));
         

            dr = dt.NewRow();
            //dr["RowNumber"] = 1;
            //dr["Col1"] = dr["RowNumber"].ToString();
            dr["Col2"] = string.Empty;
            dr["Col3"] = string.Empty;
            dr["Col4"] = string.Empty;
            dr["Col5"] = string.Empty;
            dr["Col6"] = string.Empty;
            dr["Col7"] = string.Empty;
            dr["Col8"] = string.Empty;
         

            dt.Rows.Add(dr);
            Session["CurrentTable"] = dt;
            dgdItem.DataSource = dt;
            dgdItem.DataBind();
        }


this is the grid which loads at the time of pageload. if button is clicked new row will be added. If want to add data set at the time of page load what is the prodecure
ASKER CERTIFIED SOLUTION
Avatar of jitendra patil
jitendra patil
Flag of India 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
guru , thanks for ur answer.

but my problem is how to data to grid which exactly like
http://www.aspsnippets.com/Articles/Adding-Dynamic-Rows-in-ASP.Net-GridView-Control-with-TextBoxes.aspx

and after binding . the grid should be editable this my requirement