Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Please reply me how to fill a gridview from form data dynamically (without using datasource) and without using a session

I used this way but when it browsing another time, gridview appeares with old data.What should I do?

protected

{

{

dt =Cache[

gridbindfromtextbox();

}

void btnAdd_Click(object sender, EventArgs e)if (Cache["myTable"] != null)"myTable"] as DataTable;else

{

dt.Columns.Add(

dt.Columns.Add(

gridbindfromtextbox();

}

}

{

dr[

dr[

dt.Rows.Add(dr);

Cache[

GridView1.DataSource = dt;

GridView1.DataBind();

}

"Name");"Age");public void gridbindfromtextbox()DataRow dr = dt.NewRow();"Name"] = txtNane.Text.ToString();"Age"] = txtAge.Text.ToString();"myTable"] = dt;
Posted
Updated 17-Nov-09 19:31pm
v2

1 solution

Your code is illegible.  However, given that you only have one set of textboxes, why do you need a grid ? you want to enter them and show them as you go, without storing them anywhere ? What's the use of that ? You COULD store them all in viewstate, if you wanted, but it seems pointless to me.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900