c# - Getting DropDownList values in a repeater -
There is a following mark-up code: This shows the initialization of each object can get How do I ASPX page
< Code> & lt; ASP: Repeater id = "GeneralRepeater" runat = "server" OnItemDataBound = "GeneralRepeater_OnItemDataBound" & Gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; TD & gt; Place: & lt; ASP: DropDownList ID = "GeneralDDL" DataTextField = "text" DataValueField = "Arena" runat = "server" / & gt; & Lt; / TD & gt; & Lt; Th & gt; & Lt; Asp: Button ID = "GeneralButton" runat = "server" Text = "Принять запрос" onclick = "GeneralButton_Click" / & gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: Repeater & gt;
code-behind
protected void GeneralRepeater_OnItemDataBound (object sender, RepeaterItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || E Kaitmkitmteepe == Listitenteepekalternatingitm) {Dropdunlist Meeddl = (Dropdunlist) Ikaitmkfndkantrol ( "Generldl"); MyDDL.DataSource = lstArenaSelect; MyDDL.DataBind (); MyObject obj = (MyObject) e.Item.DataItem; Button General Button = (Button) E. ITEM FontControl ("General Button"); AcceptGeneralRequestButton.CommandArgument = obj.Id; }}
with the list of the objects of the DropDownList
, and in the row that connects the row object. id
question
GeneralButton_Click
method In the dropdown list
, get the value that is located in the same repeater line?
Thanks to everyone, I have used another approach:
control parent = ((sender)). mother-father; DropDownList GeneralDDL = (DropDownList) parent.FindControl ("GeneralDDL");
The code is called onclick button event handler.
Comments
Post a Comment