在 Web 数据网格中的模板数据字段内定位 imagebutton
Targeting imagebutton inside template data field in web data grid
我在 Web 数据网格中有一个 ImageButton (ImageButton1)。我正在尝试编写一个 if 语句,如果日期小于某个日期,则图像按钮将不可见。我不知道如何定位 ImageButton。这是我的代码:
<ig:TemplateDataField Key="Export" CssClass="MinWidth45 Nowrap">
<Header Text="Map Link"></Header>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="Block(true);" OnClick="ImageButton1_Click" CssClass="Stopper" ImageUrl="~/images/ExcelExport.bmp" Height="25px" Width="24px" ToolTip="Export to Excel" EnableViewState="false"/>
</ItemTemplate>
</ig:TemplateDataField>
后端代码(通过输入它的 ID(ImageButton1) 定位它不起作用):
If e.Row.Items.FindItemByKey("Dates").Value < Date.Today Then
ImageButton1.visible = False
End If
If e.Row.Items.FindItemByKey("Dates").Value < Date.Today Then
e.Row.Items(13).FindControl("ImageButton1").Visible = False
End If
"(13)" 是我数据中列的索引 table
我在 Web 数据网格中有一个 ImageButton (ImageButton1)。我正在尝试编写一个 if 语句,如果日期小于某个日期,则图像按钮将不可见。我不知道如何定位 ImageButton。这是我的代码:
<ig:TemplateDataField Key="Export" CssClass="MinWidth45 Nowrap">
<Header Text="Map Link"></Header>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="Block(true);" OnClick="ImageButton1_Click" CssClass="Stopper" ImageUrl="~/images/ExcelExport.bmp" Height="25px" Width="24px" ToolTip="Export to Excel" EnableViewState="false"/>
</ItemTemplate>
</ig:TemplateDataField>
后端代码(通过输入它的 ID(ImageButton1) 定位它不起作用):
If e.Row.Items.FindItemByKey("Dates").Value < Date.Today Then
ImageButton1.visible = False
End If
If e.Row.Items.FindItemByKey("Dates").Value < Date.Today Then
e.Row.Items(13).FindControl("ImageButton1").Visible = False
End If
"(13)" 是我数据中列的索引 table