Hi ,
To bind the RaidButton u have to implement Radiolist_DataBound and loop through the items . I made solution but i didnt need use Request.form coz i create the Radiolist and bind it in one step .
Code behind :
protected System.Web.UI.WebControls.RadioButtonList raid;
DataClassesDataContext db = new DataClassesDataContext();
protected void Page_Load(object sender, EventArgs e)
{
}
int countTimes = 0;
protected void Button1_Click(object sender, EventArgs e)
{
if (ViewState["countTimes"] == null)
{
countTimes = 1;
}
else
{
countTimes = Convert.ToInt32(ViewState["countTimes"]);
}
for (int i = 0; i < countTimes; i++)
{
raid = new RadioButtonList();
raid.ID = "raid" + i;
form1.Controls.Add(raid);
}
countTimes = countTimes + 1;
ViewState.Add("countTimes", countTimes);
var result = from x in db.cates
select new { x.chk, x.id };
raid.DataSource = result;
raid.DataTextField = "chk";
raid.DataValueField = "chk";
raid.DataBind();
raid_DataBound(raid, new EventArgs());
}
void raid_DataBound(object sender, EventArgs e)
{
foreach (ListItem item in raid.Items)
{
item.Selected = bool.Parse(item.Value);
}
}
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
</div>
Best Regards
M.mitwalli