How to Dynamically create textboxes using ASP.NET and then save their values in Database?

后端 未结 2 1700
忘掉有多难
忘掉有多难 2020-12-20 18:53

I am creating a survey site. I want to add the textboxes dynamically and then get their values in the database.

Now let\'s say I select 4 textboxes from the dropdow

2条回答
  •  一个人的身影
    2020-12-20 19:34

    This sounds like the age-old classic problem with asp.net adding controls dynamically to a page.

    The problem is to with viewstate and reconstruction of the controls on postback.

    You need to run the same code that generated the controls on postback at the correct time in the page lifecycle to ensure postback values match server-side controls.

    Of course if you want a hacky shortcut, access the Request.Form["textCheckbox" + index] values directly

    A useful article on the subject.

提交回复
热议问题