Calendar Extender SelectedDate使用空值 [英] Calendar Extender SelectedDate Working with null values

查看:84
本文介绍了Calendar Extender SelectedDate使用空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当数据库中存在空值时,将数据绑定到Calendar Extender时遇到问题.我尝试了不同的方法,但无法正常工作.下面给了我一个

I am having an issue with binding data to a Calendar Extender when null values are in the database. I have tried different things and can not get it to work. The below gives me a

<td>
    <asp:TextBox ID="DateQualifiedTextBox" runat="server"
        Text='<%# Bind("DateQualified")  %>' />
    <asp:CalendarExtender ID="DateQualifiedTextBox_CalendarExtender" runat="server"
    Enabled="True" TargetControlID="DateQualifiedTextBox" SelectedDate='<%# IF(not IsDBNull(Bind("DateQualified")), Bind("DateQualified")  %>' >


</td>



但我得到以下信息:
编译错误

说明:编译服务该请求所需的资源期间发生错误.请查看以下特定的错误详细信息,并适当地修改您的源代码.

编译器错误消息:BC30451:未声明绑定".由于其保护级别,它可能无法访问.

源错误:




But I get the following:
Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: ''Bind'' is not declared. It may be inaccessible due to its protection level.

Source Error:


Line 310:                    <asp:TextBox ID="DateQualifiedTextBox" runat="server" 
Line 311:                        Text='<%# Bind("DateQualified")  %>' />
Line 312:                    <asp:CalendarExtender ID="DateQualifiedTextBox_CalendarExtender" runat="server" 
Line 313:                    Enabled="True" TargetControlID="DateQualifiedTextBox" SelectedDate='<%# IF(not IsDBNull(Bind("DateQualified")), Bind("DateQualified")  %>' > 
Line 314:

推荐答案

而不是Bind,请尝试使用Eval()
instead of Bind can please try with Eval()


好吧,现在我终于可以使用一些脚本和OnClientShowing
进行此工作了

< script type ="text/javascript" language ="javascript">

函数showDate(sender,args)
{
if(sender._textbox.get_element().value ==")
{
var todayDate = new Date();
sender._selectedDate = todayDate;
}
}
</script>



< asp:textbox id ="DateQualifiedTextBox" runat ="server" xmlns:asp =#unknown">
Text =''<%#Bind("DateQualified","{0:MM/dd/yyyy}")%>''/>
< asp:calendarextender id ="DateQualifiedTextBox_CalendarExtender" runat ="server">
Enabled ="True" TargetControlID ="DateQualifiedTextBox" OnClientShowing ="showDate">
Okay I finally have this working now using some script and OnClientShowing


<script type="text/javascript" language="javascript">

function showDate(sender,args)
{
if(sender._textbox.get_element().value == "")
{
var todayDate = new Date();
sender._selectedDate = todayDate;
}
}
</script>



<asp:textbox id="DateQualifiedTextBox" runat="server" xmlns:asp="#unknown">
Text=''<%#Bind("DateQualified" , "{0: MM/dd/yyyy}") %>'' />
<asp:calendarextender id="DateQualifiedTextBox_CalendarExtender" runat="server">
Enabled="True" TargetControlID="DateQualifiedTextBox" OnClientShowing="showDate" >


这篇关于Calendar Extender SelectedDate使用空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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