0
在SQL查詢之後,我有一個ASP.NET DataGrid數據綁定數據表。 DataGrid中填充了組織員工的個人信息。 每行都包含「Send Greeting」按鈕。 如果電子郵件地址爲空,那麼如果該行中的「電子郵件地址」單元格處於禁用或隱藏此按鈕的狀態。如果屬性爲空,ASP.NET(無JS!)隱藏DataGrid行中的按鈕
我的ASP代碼:
<table dir="rtl">
<tr>
<asp:Label ID="lbl1" runat="server" CssClass="bDayLable" Text="Select a rpw and click on button to send greeting"></asp:Label>
</tr>
<tr>
<td colspan="2">
<div id="divMyPath" runat="server"></div>
<div id="divResults" runat="server">
<asp:DataGrid ID="grdResult" runat="server" BorderColor="#CCCCCC" BorderWidth="2px" Font-Bold="False" Font-Italic="False" Font-Names="Segoe UI" Font-Overline="False" Font-Size="13px" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Right" AutoGenerateColumns="False" Cellpadding="2" CellSpacing="2" AllowPaging="True" PageSize="4" AllowSorting="True" OnPageIndexChanged="grdResult_PageIndexChanging">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%-- <img src="\\blabla\pictures\<%# Eval("Employeeno")%>.JPG" class="phoneBookImage" />--%>
<img src="http://intranet.somedomain.com/UserProfiles/pictures/<%# Eval("Employeeno")%>.JPG" class="phoneBookImage" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Employee Name">
<ItemTemplate>
<%# Eval("firstname") & " " & Eval("surname")%>
</ItemTemplate>
</asp:TemplateColumn>
<%-- <asp:BoundColumn DataField="EmailAdd" HeaderText="Email" DataFormatString="{0:n2}"></asp:BoundColumn>--%>
<asp:TemplateColumn HeaderText="Email">
<ItemTemplate>
<a href='mailto:<%# Eval("EmailAdd")%>'> <%# Eval("EmailAdd")%> </a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Greeting">
<ItemTemplate>
<asp:Button ButtonType="Button" ID="btnSendGreeting" runat="server" CssClass="btnSendGreeting" Text="Send Greeting" Visible="true" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<FooterStyle BackColor="#00CC00" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
<HeaderStyle BackColor="Gray" Font-Bold="True" Font-Italic="False" Font-Names="Segoe UI" Font-Overline="False" Font-Size="Small" Font-Strikeout="False" Font-Underline="False" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle" />
<SelectedItemStyle BackColor="#CCFFCC" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" />
</asp:DataGrid>
</div>
</td>
</tr>
我的代碼背後包含了功能,以填補因數據表DataGrid中。 在此先感謝!
非常感謝。這很好。對於那些看這個的人來說,VB版本是這樣的:Enabled ='<%#Eval(「EmailAdd」)IsNot Nothing AndAlso Not String.IsNullOrEmpty(Eval(「EmailAdd」)。ToString())%>' – 2014-09-04 10:49:10