开发者

Access a Label via a DropDownlist_selectedindexchanged event , both in a Listview

is it possible to access the CouncilIdLabel via DropDownList_SelectedIndexChanged event?!

<tr id="Tr10" runat="server">
            <td width="110px">
                دسته :&nbsp;
            </td>
            <td>
                <asp:DropDownList ID="CategoryDropDownList" runat="server" Font-Names="tahoma" Font-Size="13px" 开发者_开发问答onselectedindexchanged="CategoryDropDownList_SelectedIndexChanged" AutoPostBack="true" SelectedValue='<%# Eval("Category") %>'>
                    <asp:ListItem Text="عمومی" Value="عمومی"></asp:ListItem>
                    <asp:ListItem Text="پزشکی" Value="پزشکی"></asp:ListItem>
                    <asp:ListItem Text="مددکاری" Value="مددکاری"></asp:ListItem>
                    <asp:ListItem Text="روان شناسی" Value="روان شناسی"></asp:ListItem>
                </asp:DropDownList>
                <asp:Label ID="CouncilIdLabel" runat="server" Text='<%# Eval("CouncilId") %>' Visible="false" />
            </td>
        </tr>

it is located in a listview ItemTemplate

please help me, i need to solve this problem really soon


You need to use FindControl on the ListViewDataItem itself. i.e.

Label coucilIdLabel = (Label)SomeListView.Items[SomeItemIndex].FindControl("CouncilIdLabel");

Or - In your selectedIndex changed event, this should work:

var item = sender.Parent as ListViewDataItem;
Label coucilIdLabel = (Label)item.FindControl("CouncilIdLabel");


Yes, it is possible. You'll have to find the control in the listview. Use:

Label coucilIdLabel = (Label)MyListView.FindControl("CouncilIdLabel");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜