如何将项模板(eval)值分配给asp.net gridview控件外部的标签
本文关键字:net asp gridview 控件 标签 外部 分配 eval | 更新日期: 2023-09-27 18:18:11
我想把
<%# DataBinder.Eval(Container.DataItem, "Name")%>
,它在gridview内,并且是一个标签
Label2
在gridview之外。我无法找出一种方法来做到这一点,因为Eval值是在Gridview和我需要在gridview之外使用它。我有下面的代码:
请告诉我。
<div class="ModalPopup" id="PopupDiv1">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<div class="modalHeader">
<table width="100%">
<tr>
<td class="title">
<asp:Label ID="Label2" Font-Bold="true" runat="server"></asp:Label>
</td>
<td>
<a href="javascript:void(0);" onclick="javascript:CloseModelPopup1();" class="CloseModal">
X</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<div id="Div1" class="InsertBar">
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="left" ScrollBars="Auto">
<asp:GridView ID="gDetails" OnRowDataBound="gvDetails_RowDataBound"
Orunat="server" CellPadding="5"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image Width="32px" ID="statusImage" runat="server" Height="32px"></asp:Image>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LogId">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "LogId") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Name")%> </ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</div>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Try this out
<div class="ModalPopup" id="PopupDiv1">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<div class="modalHeader">
<table width="100%">
<tr>
<td class="title">
<asp:Label ID="Label2" Font-Bold="true" runat="server"></asp:Label>
</td>
<td>
<a href="javascript:void(0);" onclick="javascript:CloseModelPopup1();" class="CloseModal">
X</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<div id="Div1" class="InsertBar">
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="left" ScrollBars="Auto">
<asp:GridView ID="gDetails" OnRowDataBound="gvDetails_RowDataBound"
Orunat="server" CellPadding="5"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image Width="32px" ID="statusImage" runat="server" Height="32px"></asp:Image>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LogId">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "LogId") %>
CommandArgument='<%# Container.DataItemIndex %>' runat="server" ID="btnRequest"></asp:LinkButton>--%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Name")%> </ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</div>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>