Вопрос

ASP.NET with AjaxContolToolkit.

I have a CalendarExtender inside editable GridView control.

I want to do a simple thing: assing an existring date value of TextBox.Text or Label.Text to the SelectedDate attribute to make editing more user-friendly. The task is pretty simple, isn't it?!

...
<ItemTemplate>
<asp:Label ID="accdateLbl" runat="server" Text='<%# Bind("totalaccdate") %>'></asp:Label> 
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="accdateEditTxtBox" runat="server" Text='<%# Eval("totalaccdate") %>' ReadOnly="True" />
<asp:CalendarExtender ID="accdateEditTxtBoxCalendarExtender" runat="server" TargetControlID="accdateEditTxtBox" Format="dd-MM-yyyy" PopupButtonID="accdateEditCalImage" 
StartDate="01-01-2011" EndDate='<%# DateTime.Now %>' SelectedDate='???'/>
<asp:Image ID="accdateEditCalImage" runat="server" ImageUrl="~/images/calendar.gif" />
</EditItemTemplate>
...

I've tried many snippets, nothing helped!

And, please, could it be done without additional JavaScript.

Thank you!

Это было полезно?

Решение

You don't need to specify the SelectedDate because it is the date that is already in the TextBox. So you can set the TextBox.Text property and it will be taken as the SelectedDate automatically.

But you need to to use the same format as the CalendarExtender uses.

In your case (for example in the GridView's RowDataBound event):

accdateEditTxtBox.Text = theDate.ToString("dd-MM-yyyy");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top