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


I Have gridview by default no columns declared in the aspx page. I declared the columns dynamically based on the requirement. I have a subject dropdownlist control ,inwhich selectedIndexchanged event I created dynamic columns(label,and textbox) show in the page.. For label control I bind the data from database and for Textbox i just enter the data from here. Outside the gridview I Have the button for save this gridview value to database.In button click event i would like call the gridview data for saving in the database. But I Have an issue with gridview state level.In this button click event postback, gridview loses their data value,so i cannot able to read the data from gridview. what is my task is I want to read the gridview data to save to database. help me.

I post my code previously. but no result. i tried my level best.
how can maintain viewstate for gridview for different postback[^]
Posted
Comments
Please show the Page Load Code.
baskaran chellasamy 4-Oct-13 10:15am    
protected void Page_Load(object sender, EventArgs e)
{
Button1.Visible = false;
Button2.Visible = false;
if (!IsPostBack)
{
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
DataTable acyear = inter.bindacademicyears(year,month);
// acyeardropdown.Items.Insert(0, "Select Year");
for (int i = 0; i < acyear.Rows.Count; i++)
{
acyeardropdown.Items.Add(acyear.Rows[i]["FromYear"].ToString() + "-" + acyear.Rows[i]["ToYear"].ToString());

}
bindmedium();
bindclass();
studmarkgrid.DataBind();

}
baskaran chellasamy 4-Oct-13 10:18am    
I have created the gridview columns dynamically in the subjectdropdown_selectedIndexChanged event not in the page_load event. and my gridiew has editable textbox control. in that i enter mark then only i pass this grid in the another button click event.
baskaran chellasamy 4-Oct-13 10:22am    
anything friend

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