This is a migrated thread and some comments may be shown as answers.

a call to bind was not well formed ?

3 Answers 215 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Neeraj
Top achievements
Rank 1
Neeraj asked on 14 May 2009, 07:42 PM
I am getting an error in the below code........what am I doing wrong ? 
-- error with this because of the conditional statement <telerik:RadDatePicker ID="radBillPeriodStartDate1" Skin="Office2007" Style="vertical-align: middle;" runat="server" DbSelectedDate='<%# Bind("END_BILLING_PERIOD","{0:D}") == DBNull.Value ? radBillPeriodEndDate.SelectedDate : Bind("END_BILLING_PERIOD","{0:D}") %>' > -- this works fine when there is no conditional statement <telerik:RadDatePicker ID="radBillPeriodEndDate1" Skin="Office2007" Style="vertical-align: middle;" runat="server" DbSelectedDate='<%# Bind("END_BILLING_PERIOD", "{0:d}") %>' >

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 15 May 2009, 05:24 AM
Hello Neeraj,

You cannot use Bind with such conditions.
Please refer to the documentation of how data-binding expressions:
Data-Binding Expressions Overview
How ASP.NET databinding deals with Eval() and Bind() statements

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Neeraj
Top achievements
Rank 1
answered on 15 May 2009, 02:57 PM
ok thanks for that. Here is my problem , I have a raddatepicker bound to a radgrid. When I add a new item, I need to assign a datevalue from an existing control that I have on the page, and when the user edits this value, get that value saved to the database.
I have the following code which works but when a user edits it the value is not getting bound to the data, it resets it to 01/01/0001. Because there is no InsertItemTemplate in radGrid is there a way to achieve this ? 


<

 

telerik:GridTemplateColumn HeaderText="Billing Period Start Date" UniqueName="BEGIN_BILLING_PERIOD"

 

 

EditFormColumnIndex="1">

 

 

<HeaderStyle Width="62px" />

 

 

<ItemTemplate>

 

 

<asp:Label runat="server" ID="lblBillingPeriodStartDate" Text='<%# Eval("BEGIN_BILLING_PERIOD", "{0:D}") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

<telerik:RadDatePicker ID="radBillPeriodStartDate1" Skin="Office2007" Style="vertical-align: middle;"

 

 

runat="server" DbSelectedDate='<%#GetDateValue(Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "BEGIN_BILLING_PERIOD")))%>'

 

 

>

 

 

<Calendar ShowRowHeaders="false" />

 

 

</telerik:RadDatePicker>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 



protected

 

DateTime GetDateValue(DateTime d)

 

{

 

DateTime retValue;

 

 

if (d == null)

 

{

retValue =

DateTime.Parse(radBillPeriodEndDate.SelectedDate.ToString());

 

}

 

else

 

{

retValue = d;

 

//Convert.ToDateTime(d, "{0:d}");

 

}

 

return retValue;

 

}

0
Accepted
Sebastian
Telerik team
answered on 18 May 2009, 01:49 PM
Hi Neeraj,

How to perform update/insert with RadDatePicker inside edit template of RadGrid template column and set predefined date on init insert you can see from the sample project in this KB article on our site.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Neeraj
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Neeraj
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or