如果gridview中列的值为空,则隐藏控件 [英] Hide the control if value of a column is empty in a gridview

查看:222
本文介绍了如果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(技能)%>









< tr>
工作地点:<%#Eval(LocationName)%> < asp:ImageButton ID =ImageButton1OnClick =ImageButton1_ClickCommandArgument ='<%#Eval(WalkinID)%>'ImageUrl =〜/ images / apply.pngrunat = server/>
< asp:Label ID =maillblrunat =serverText ='<%#Eval( ContactMail)%>'>
< asp:Label ID =resltlblrunat =serverText =LabelVisible =FalseCssClass =Confirm_Msg> ;



< 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 horizo​​ntalalign = 中心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")%>





Job Location :<%# Eval("LocationName")%> <asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" CommandArgument='<%# Eval("WalkinID")%>' ImageUrl="~/images/apply.png" runat="server" />
<asp:Label ID="maillbl" runat="server" Text='<%# Eval("ContactMail")%>' >
<asp:Label ID="resltlbl" runat="server" Text="Label" Visible="False" CssClass="Confirm_Msg">





<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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆