DataTable in ASP.Net Session

后端 未结 2 1711
萌比男神i
萌比男神i 2021-01-26 11:56

I have to show users entered parameters in Asp.net Gridview example some values from dropdownlist textboxes and startDate EndDate etc . I am getting these values from user and a

相关标签:
2条回答
  • 2021-01-26 12:32

    Am not sure for you scenario. But here is the thing for adding grid view dynamically without using database.

     protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            DataTable date = new DataTable();
            date.Columns.Add("Column !", typeof(string));
            date.Columns.Add("Column 2", typeof(string));
            Session["dte"] = date;
         }
     }
    
    protected void addbutton_Click(object sender, ImageClickEventArgs e)
    {
        DataTable date = (DataTable)Session["dte"];
        DataRow dr = date.NewRow();
        dr["Column 1"] = TextBox1.Text.Trim();// Your Values
        dr["Column 2"] = TextBox2.Text.Trim();// Your Values
        date.Rows.Add(dr);
        GridView1.DataSource = date;
        GridView1.DataBind();
    }
    

    It may help you to over come this hurdle. Please let me know your further queries in this case.

    0 讨论(0)
  • 2021-01-26 12:57

    You need to get the previous datatable from session and read it and put rows in it. This should be done at addrow AddButton_Click event.

    0 讨论(0)
提交回复
热议问题