Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

c# - dynamically adding check box asp.net( csharp) and retain its value on postback

I need to add dynamically checkboxlist to a section of web page. I also need to retain its value on post back. How this should be done?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to add any dynamic controls in page_init if you want their values on postback.

For example:

void Page_Init(object Sender, System.EventArgs e)
{
   var oList = new CheckBoxList();
   // Populate the values in the list
   this.Controls.Add(oList);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...