gridview中的访问控制ID [英] Access control id in gridview
本文介绍了gridview中的访问控制ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview.In gridview标题行我有一个链接按钮和组合框。我在组合框中选择一个值并执行事件。我的问题是我想在组合框中执行事件时获取linkbutton控件ID。标题行内的每个模板字段中都有一个组合框和链接按钮。所以我想要最近的链接按钮id。可以使用C#代码吗
我尝试过:
I have a gridview.In gridview header row I have one link button and combo box.I am selecting one value in combobox and performing events.My problem is that I want to get linkbutton control id when I perform event in combobox.There are one combobox and link button in each template field inside header row.So I want closest link button id.is it possible to do using C# code
What I have tried:
<asp:GridView ID="GridViewemp" runat="server" AllowPaging="True" class="gv"
AllowSorting="True" onpageindexchanging="GridViewemp_PageIndexChanging"
BorderColor="#3399FF" BorderStyle="Groove"
CellPadding="1" CellSpacing="1"
onsorting="GridViewemp_Sorting" PageSize="5" AutoGenerateColumns="False"
Height="10px" onselectedindexchanged="GridViewemp_SelectedIndexChanged"
onrowdatabound="GridViewemp_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="E_Id ●" ControlStyle-Font-Names="Arial" SortExpression="eid" >
<HeaderTemplate>
<asp:LinkButton ID="linkid" runat="server" Text="E_Id ●"
CommandName="Sort" CommandArgument="eid"
CssClass="RightAlign" ForeColor="Black"></asp:LinkButton>
<br />
<table>
<tr>
<td>
<cc1:ComboBox ID="ComboBoid" runat="server" AutoCompleteMode="SuggestAppend" DropDownStyle="Simple"
Width="50px" AutoPostBack="true" OnSelectedIndexChanged="filter" >
</cc1:ComboBox>
</td>
</tr>
</table></HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblid" runat="server" Text='<%#Eval("eid")%>'/>
</ItemTemplate>
<ControlStyle Font-Names="Arial"></ControlStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="E_Name ●" SortExpression="ename" ShowHeader="true" >
<HeaderTemplate>
<asp:LinkButton ID="linkname" runat="server" Text="E_Name ●"
CommandName="Sort" CommandArgument="ename"
CssClass="RightAlign" ForeColor="Black"></asp:LinkButton>
<br />
<table>
<tr>
<td>
<cc1:ComboBox ID="ComboBoxname" runat="server" AutoCompleteMode="SuggestAppend" DropDownStyle="Simple"
Width="50px" OnSelectedIndexChanged="filter" AutoPostBack="true" >
</cc1:ComboBox>
</td>
</tr>
</table></HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblname" runat="server" Text='<%#Eval("ename")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Names="Times New Roman" Font-Size="Small"
ForeColor="Black" CssClass="header" Wrap="False" />
</asp:GridView>
推荐答案
请参阅下面的事件冒泡链接。
c# - 在datagridview内部进行组合框项目选择的事件冒泡 - Stack Overflow [ Databridview中Combobox的事件冒泡]
refer to the below Link for event bubbling.
c# - event bubbling for combobox item selection which is inside the datagridview - Stack Overflow[Event bubbling for Combobox in Datagridview]
这篇关于gridview中的访问控制ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文