我有一个中继器,我有一些控件,如下拉列表和文本框我如何捕捉下拉选择的值和在文本框中输入的值并将它们存储在隐藏字段中?
它就像一个公式Left(c1+c2)*c3
,格式是这样的。
中继器代码:
<asp:Repeater ID='myRepeater' runat="server" OnItemDataBound='myRepeater_OnItemDataBound'>
<ItemTemplate>
<asp:HiddenField ID='myHidden' runat="server" />
<asp:DropDownList ID="GeneralDDL" runat="server" AutoPostBack="True" />
</ItemTemplate>
</asp:Repeater>
**Code behind :**
protected void myRepeater_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
var myHidden = (HiddenField)e.Item.FindControl("myHidden");
foreach(RepeaterItem dataItem in 'myRepeater.Items)
{
myHidden.Value = ((DropDownList)'myRepeater.FindControl("GeneralDDL")).SelectedItem.Text;
// Same like for Text box
}
}