如果gridview中列的值为空,则隐藏控件 [英] Hide the control if value of a column is empty in a gridview
问题描述
我已在gridview中绑定作业列表。职位,工作地点,联系信箱 - 这些是我在gridview中绑定的字段....如果contactmail为null或为空,则应用图像按钮必须为该特定工作隐藏...我该怎么做... 。
ASPX页面:
< asp:GridView ID =GridView1GridLines =None BorderStyle =无runat =serverWidth =100%AutoGenerateColumns =False
onpageindexchanging =GridView1_PageIndexChangingAllowPaging =TruePageSize =20OnRowDataBound =GridView1_RowDataBound >
< columns>
< asp:TemplateField ControlStyle-BorderStyle =无>
< itemtemplate>
<%#Eval(Walkin_Title)%> ; - Exp。[<%#Eval(Exp)%>] <% #Eval(Company_Name)%> 技能:<%#Eval(技能)%>
|
< br $>
< pagersettings firstpagetext =lastpagetext =>
Mode =NextPreviousFirstLastNextPageText =
PreviousPageText =PreviousFirstPageImageUrl =〜/ images / First_arrow.png
LastPageImageUrl =〜/ images / Last_Arrow.png
NextPageImageUrl =〜/ images / Next_arrow.png
PreviousPageImageUrl =〜/ images / previous_arrow.png/>
< pagerstyle horizontalalign = 中心verticalalign =底部>
您好,您可以尝试这样,
< asp:label id = maillbl runat = server visible =' <% #Eval(< span class =code-string> ContactMail)。ToString()!= ? true : false % >' text = <% #Eval( ContactMail)%> xmlns:asp = #unknown >
< / asp:label >
隐藏图像按钮
< asp:ImageButton ID = < span class =code-keyword> ImageButton1 可见 =' <% #Eval( ContactMail)!= ? true : false %>' OnClick = ImageButton1_Click CommandArgument =' <% #Eval( < span class =code-string> WalkinID)%>' ImageUrl = 〜/ images / apply.png runat = server / > 跨度>
I have bind the job list in my gridview. job title,job location,contactmail-these are fields i have bind in the gridview....If the contactmail is null or empty then apply image button must be hide for that particular job... How can i do that....
ASPX PAGE :
<asp:GridView ID="GridView1" GridLines="None" BorderStyle="None" runat="server" Width="100%" AutoGenerateColumns="False"
onpageindexchanging="GridView1_PageIndexChanging" AllowPaging="True" PageSize="20" OnRowDataBound="GridView1_RowDataBound" >
<columns>
<asp:TemplateField ControlStyle-BorderStyle="None">
<itemtemplate>
<%# Eval("Walkin_Title") %>--Exp.[<%#Eval("Exp")%>] <%#Eval("Company_Name")%> Skills :<%#Eval("Skills")%>
|
<pagersettings firstpagetext="" lastpagetext="">
Mode="NextPreviousFirstLast" NextPageText=""
PreviousPageText="Previous" FirstPageImageUrl="~/images/First_arrow.png"
LastPageImageUrl="~/images/Last_Arrow.png"
NextPageImageUrl="~/images/Next_arrow.png"
PreviousPageImageUrl="~/images/previous_arrow.png" />
<pagerstyle horizontalalign="Center" verticalalign="Bottom">
Hi you can try like this,
<asp:label id="maillbl" runat="server" visible='<%# Eval("ContactMail").ToString()!=""?true:false %>' text="<%# Eval("ContactMail")%>" xmlns:asp="#unknown"> </asp:label> To hide the image button <asp:ImageButton ID="ImageButton1" Visible='<%# Eval("ContactMail")!=""?true:false %>' OnClick="ImageButton1_Click" CommandArgument='<%# Eval("WalkinID")%>' ImageUrl="~/images/apply.png" runat="server" />
这篇关于如果gridview中列的值为空,则隐藏控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!