4

When using the bind method in the calendar control I get the error: The name 'Bind' does not exist in the current context. How Can I do this correctly? I need a way of checking against null values. it is within a Gridview control

<asp:Calendar ID="Calendar1" runat="server" SelectedDate='<%# string.IsNullOrEmpty(Bind("valid_date").ToString()) ? "0000-00-00 00:00:00.000": Bind("valid_date").ToString() %>' ></asp:Calendar>
2
  • What are you trying to bind? Is this in a GridView or some other similar databound control? Where is valid_from_date coming from? Commented Mar 5, 2014 at 16:40
  • @DaveZych its in a GridView Commented Mar 5, 2014 at 16:42

2 Answers 2

3
SelectedDate = '<%# String.IsNullOrEmpty(Convert.ToString(Eval("valid_date"))) ? DateTime.MinValue : Eval("valid_date") %>'
Sign up to request clarification or add additional context in comments.

1 Comment

Some explanation would help a lot. Why can't we use 'bind'? Is it deprecated or what?
0

I think what you're looking for is Eval:

<asp:Calendar ID="Calendar1" runat="server" 
    SelectedDate='<%# string.IsNullOrEmpty(Eval("valid_date").ToString()) ? "0000-00-00 00:00:00.000": Eval("valid_date").ToString() %>'>
</asp:Calendar>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.