如何在基于条件的Gridview列字段中显示空值或值 [英] How Do I Display Null Or Values In Gridview Column Field Based On Condition
问题描述
我正在使用gridview的绑定字段。在其中,如果来自数据库的boundfield中的值是1/1/1999,我希望在列中显示null。如果没有,此字段中的值必须与数据库中的值相同...我尝试使用以下标记,但它不起作用..
< columns>< ; asp:BoundField DataField ='<%if(Promised_Date_Time ==1/1/1999?:Promised_Date_Time)%>>'HeaderText =Promise Date TimeDataFormatString ={0:MM / dd / yyyy}/>
任何帮助???
试试这个..
< asp:TemplateField >
< ItemTemplate >
< asp:Label ID = < span class =code-keyword> lbl runat = server 文本 =' <% #Eval( Promised_Date_Time)== 1/1 / 1999\" 跨度>? :Eval( Promised_Date_Time)%>' > < ; / asp:标签 >
< / ItemTemplate >
< / asp:TemplateField >
I am using a bound field of gridview.. In it, if the value that comes in boundfield from database is 1/1/1999 , i want null to be displayed in the column. If not, value in this field must be the same as it is database... I tried following tag but it is not working..
<columns><asp:BoundField DataField=" '<% if(Promised_Date_Time == "1/1/1999"? "":Promised_Date_Time) %>>' " HeaderText="Promise Date Time" DataFormatString="{0:MM/dd/yyyy}"/>
any help???
Try this..
<asp:TemplateField> <ItemTemplate> <asp:Label ID="lbl" runat="server" Text='<%# Eval("Promised_Date_Time") == "1/1/1999"? "":Eval("Promised_Date_Time") %>'></asp:Label> </ItemTemplate> </asp:TemplateField>
这篇关于如何在基于条件的Gridview列字段中显示空值或值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!