我的要求是我需要获取动态创建的单选按钮值或放置在占位符控件中的文本以及如何垂直排列控件,下面我附上了快照供您参考,请帮助我
页面:
<div id="authenticationModes">
<asp:PlaceHolder ID="plhldrAuthModes1" runat="server" >
</asp:PlaceHolder>
<asp:Button ID="btnAuthModeSave" runat="server" Text="Save Authentication Mode"
onclick="btnAuthModeSave_Click" />
</div>
服务器端编码:
protected void Page_Load(object sender, EventArgs e)
{
//...... Database coding
foreach (DataRow authModeObj in ds.Tables[0].Rows)
{
RadioButton rdoAuthModeSingleFactor = new RadioButton();
rdoAuthModeSingleFactor.Text = authModeObj["AuthenticationModes"].ToString();
string authModeIdVal = authModeObj["AuthenticationModeId"].ToString();
rdoAuthModeSingleFactor.GroupName = "AuthModes";
rdoAuthModeSingleFactor.ID = "AuthModeRdoID";
rdoAuthModeSingleFactor.Attributes.Add("Value", authModeIdVal);
plhldrAuthModes1.Controls.Add(rdoAuthModeSingleFactor);
}
}
protected void btnAuthModeSave_Click(object sender, EventArgs e)
{
//I tried this piece of code but iam getting error
RadioButton rdo = (RadioButton)plhldrAuthModes1.NamingContainer.FindControl("AuthModeRdoID");
string authenticationModeCheckedVal = rdo.Text.ToString();
}