c# - Adding rows to a table based on user input (ASP.NEt) -
i have textbox entry field user enter integer value. , there "create" button, when clicked upon must generate table 2 columns : "name" , "email" being column headers.
i want each row have textbox in each of these columns.
all of has happen after button clicked. have discovered if dynamically add control in asp.net(i using c#) controls lost during postback. , don't know how prevent happening.
can please give me ideas regarding how go adding rows dynamically table (i tried using asp.net server side table control ran "lost-during-postback" problem - can try else gridview ? afaik gv not work without data bound )
point note table has textboxes user entry , not showing data ..rather accepting data user later used persist details database.
dynamic controls
that's involved. here's interesting article on issue of dynamic controls.
i think if create dynamic controls you're responsible recreating them on postback; article contains way use init event if it's copacetic app.
edit:
or regular asp.net controls
you can use data bound asp.net controls like: datalist, repeater, gridview, etc. (you can put text boxes , other kinds of controls them repeating in each row - or "item") , bind values it. if need perform processing on user input first, generate internal array, list, dictionary, datatable etc. (your choice) , bind data data source asp.net control of choice.
aspnetcontrol.datasource = mydatatable; aspnetcontrol.databind();
or
aspnetcontrol.datasourceid = "name_of_control";
there various ways assign data source.
this way won't run same problems dynamic control creation; there lot learn facilitate way too.
Comments
Post a Comment