문제

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