c# - No backend database, only dynamically created table bound to GridView -
i need solution this: no backend database, no xml, no excel, when user gives information display in griddata. creating dynamically in .aspx.cs
table , column ...
eg:--
name |-text box-| button
gridview
when user visited page ..like above name textbox , submit button .
when user enters name in textbox , clicks on submit want add name grid, here want not presented data... previous enter data display in gridview.
eg2:-
sairam submit--->click pamidi submit-->click
i want display how many values user enter many want display in gridview ,like this
sairam pamidi some.... more... values..
up-to when user perform close of browser .
info.aspx
:
<form id="form1" runat="server"> <div> <asp:label id="label1" runat="server" text="enter name"></asp:label> <asp:textbox id="textbox1" runat="server"></asp:textbox> <asp:button id="btnsumbit" runat="server" text="submit" onclick="btnsumbit_click" /> <asp:gridview id="aspgrid1" runat="server" autogeneratecolumns="false" > <columns> <asp:templatefield> <itemtemplate> <%#eval("name") %> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> </div> </form>
info.aspx.cs
:
public partial class default6 : system.web.ui.page { datatable dt = new datatable(); protected void page_load(object sender, eventargs e) { dt.columns.add("name", typeof(string)); dt.rows.add(textbox1.text); viewstate["datatable"] = dt; } protected void btnsumbit_click(object sender, eventargs e) { if (textbox1.text == " ") { return; } else if (textbox1.text != string.empty) { aspgrid1.datasource = (datatable)viewstate["datatable"]; aspgrid1.databind(); } } }
you have persist data somehow.
the standard options include database, variable stored in session state or in-page hidden fields. .net control isn't going databind it's own viewstate
.
a non-standard option handle client side without post backs. if go route better served not using standard .net controls rather use straight html. require fair bit of coding.
Comments
Post a Comment