Click here to Skip to main content
15,884,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

ASP.NET
<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>


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:


C#
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:
Posted
Updated 11-Dec-11 16:58pm
v2
Comments
Andy Morris 12-Dec-11 7:45am    
I tried the Eval also but I get the following error:
Server Error in '/' Application.

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: BC30691: 'Nullable' is a type in 'System' and cannot be used as an expression.

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(Eval("DateQualified")), Eval("DateQualified") %>' >
Line 314:

Source File: C:\Users\Andy\Desktop\PKL_QMWh\PKL_QMW\PersonnelMain.aspx Line: 312

instead of Bind can please try with Eval()
 
Share this answer
 
Comments
Andy Morris 13-Dec-11 20:17pm    
I tried the Eval also but I get the following error:
Server Error in '/' Application.

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: BC30691: 'Nullable' is a type in 'System' and cannot be used as an expression.

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(Eval("DateQualified")), Eval("DateQualified") %>' >
Line 314:

Source File: C:\Users\Andy\Desktop\PKL_QMWh\PKL_QMW\PersonnelMain.aspx Line: 312
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" >
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900