Gridview:如何通过下拉列表刷新Timepicker值?
在我的 gridview 中,我使用 MKB Timepicker 让用户输入时间。现在我想在gridview中添加一个下拉列表,当用户选择下拉列表时,它会自动刷新时间选择器值(开始时间,结束时间)。但我不知道如何在行更新/编辑模板时刷新该值。请帮忙。
谢谢 Joe
ASP 代码:
<EditItemTemplate>
<asp:DropDownList ID="ddl1_shifttype" runat ="server" AutoPostBack ="true" DataSourceID="SqlDataSource2" DataTextField ="en_name" DataValueField ="shift_type_key" SelectedValue='<%# Bind("Col1_ShiftType") %>' OnSelectedIndexChanged ="ddl1_shifttype_SelectedIndexChanged"></asp:DropDownList>
From:
<MKB:TimeSelector ID="Col1_StartTime" runat="server" DisplaySeconds="False" MinuteIncrement="1" BorderColor="Silver"
Date="" SelectedTimeFormat="Twelve"
Hour='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeHr")%>'
Minute ='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeMin")%>'
AmPm ='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeAMPM")%>'></MKB:TimeSelector>
To:
<MKB:TimeSelector ID="Col1_EndTime" runat="server" DisplaySeconds="False" MinuteIncrement="1" BorderColor="Silver"
Date="" SelectedTimeFormat="Twelve"
Hour='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeHr")%>'
Minute ='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeMin")%>'
AmPm ='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeAMPM")%>'></MKB:TimeSelector>
</EditItemTemplate>
SelectIndexChange 事件:
Protected Sub ddl1_shifttype_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1_shifttype.SelectedIndexChanged
'Testing
Col1_StartTime.Hour = "09"
Col1_StartTime.Minute = "33"
Col1_StartTime.AmPm = TimeSelector.AmPmSpec.PM
End Sub
In my gridview, I had used MKB Timepicker to let user input time. Now I want to add a dropdownlists in the gridview, when user select dropdownlists, it will automatically refresh the timepicker value (start time, end time). But I have no idea how to refresh the value when rowupdating/edit template. Please help.
Thanks
Joe
ASP code:
<EditItemTemplate>
<asp:DropDownList ID="ddl1_shifttype" runat ="server" AutoPostBack ="true" DataSourceID="SqlDataSource2" DataTextField ="en_name" DataValueField ="shift_type_key" SelectedValue='<%# Bind("Col1_ShiftType") %>' OnSelectedIndexChanged ="ddl1_shifttype_SelectedIndexChanged"></asp:DropDownList>
From:
<MKB:TimeSelector ID="Col1_StartTime" runat="server" DisplaySeconds="False" MinuteIncrement="1" BorderColor="Silver"
Date="" SelectedTimeFormat="Twelve"
Hour='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeHr")%>'
Minute ='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeMin")%>'
AmPm ='<%#DataBinder.Eval(Container.DataItem, "Col1_StartTimeAMPM")%>'></MKB:TimeSelector>
To:
<MKB:TimeSelector ID="Col1_EndTime" runat="server" DisplaySeconds="False" MinuteIncrement="1" BorderColor="Silver"
Date="" SelectedTimeFormat="Twelve"
Hour='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeHr")%>'
Minute ='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeMin")%>'
AmPm ='<%#DataBinder.Eval(Container.DataItem, "Col1_EndTimeAMPM")%>'></MKB:TimeSelector>
</EditItemTemplate>
SelectIndexChange Event:
Protected Sub ddl1_shifttype_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1_shifttype.SelectedIndexChanged
'Testing
Col1_StartTime.Hour = "09"
Col1_StartTime.Minute = "33"
Col1_StartTime.AmPm = TimeSelector.AmPmSpec.PM
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 DropDownList SelectedIndexChanged 事件中,编写代码以使用 FindControl 刷新 TimePicker。
In the DropDownList SelectedIndexChanged Event, Write the Code to Refresh the TimePicker by using FindControl.
问题解决了。以下是代码:
Problem solved. the following are the code: