page containing datatable has to be built and rebuilt again and again
-
hello, I have a gridview in a webpage where i use a datatable to populate the gridview,but only if the website is built and rebuilt the webpage works properly without exceptions,as the datatable does not retain any data that has been asign to it on the button click. Following is the code,
static DataTable dtvalues = new DataTable();
public static IICDServices icdObj;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{} } private void Createdatatable() { dtvalues.Columns.Add("DL\_No"); dtvalues.Columns.Add("F\_Name"); dtvalues.Columns.Add("M\_Name"); dtvalues.Columns.Add("L\_Name"); dtvalues.Columns.Add("Unit"); dtvalues.Columns.Add("Birth\_Date"); dtvalues.Columns.Add("Mobile\_No"); }
//on the add button click i want all data from the textboxes to be assigned to the datatable.
for which i have written the following code{
DataRow drvalues = dtvalues.NewRow(); drvalues\["DL\_No"\] = TxtDLNO.Text.ToUpper(); drvalues\["F\_Name"\] = txtFname.Text; drvalues\["M\_Name"\] = txtMName.Text; drvalues\["L\_Name"\] = txtLName.Text; drvalues\["Unit"\] = ddlUnit.SelectedItem.Text; drvalues\["Birth\_Date"\] = Gmdatepicker3.Date; drvalues\["Mobile\_No"\] = TxtMobileNo.Text; dtvalues.Rows.Add(drvalues); GridView1.DataSource = dtvalues; GridView1.DataBind(); TxtDLNO.Text = ""; txtFname.Text = ""; txtMName.Text = ""; txtLName.Text = ""; TxtMobileNo.Text = ""; }
on the submit button click i want to redirect this page back to itself but it throws an exception as the page has npt been rebuilt.
please help me out with this.
thanks. -
hello, I have a gridview in a webpage where i use a datatable to populate the gridview,but only if the website is built and rebuilt the webpage works properly without exceptions,as the datatable does not retain any data that has been asign to it on the button click. Following is the code,
static DataTable dtvalues = new DataTable();
public static IICDServices icdObj;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{} } private void Createdatatable() { dtvalues.Columns.Add("DL\_No"); dtvalues.Columns.Add("F\_Name"); dtvalues.Columns.Add("M\_Name"); dtvalues.Columns.Add("L\_Name"); dtvalues.Columns.Add("Unit"); dtvalues.Columns.Add("Birth\_Date"); dtvalues.Columns.Add("Mobile\_No"); }
//on the add button click i want all data from the textboxes to be assigned to the datatable.
for which i have written the following code{
DataRow drvalues = dtvalues.NewRow(); drvalues\["DL\_No"\] = TxtDLNO.Text.ToUpper(); drvalues\["F\_Name"\] = txtFname.Text; drvalues\["M\_Name"\] = txtMName.Text; drvalues\["L\_Name"\] = txtLName.Text; drvalues\["Unit"\] = ddlUnit.SelectedItem.Text; drvalues\["Birth\_Date"\] = Gmdatepicker3.Date; drvalues\["Mobile\_No"\] = TxtMobileNo.Text; dtvalues.Rows.Add(drvalues); GridView1.DataSource = dtvalues; GridView1.DataBind(); TxtDLNO.Text = ""; txtFname.Text = ""; txtMName.Text = ""; txtLName.Text = ""; TxtMobileNo.Text = ""; }
on the submit button click i want to redirect this page back to itself but it throws an exception as the page has npt been rebuilt.
please help me out with this.
thanks.So you want to page should maintain the data after button click or what ?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.