如何从gridview中的TimeSelector检索时间? [英] how to retrieve the time from the TimeSelector in the gridview?
本文介绍了如何从gridview中的TimeSelector检索时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview,里面有一个TimeSelector,但是我要如何从gridview检索时间,如果通常是TextBox,我们将使用此
i have a gridview and inside i have a TimeSelector, but how am i going to retrieve the time from the gridview cause if normally it is a TextBox we will use this
Dim rbSelect As TextBox = DirectCast(GridView2.Cells(1).FindControl("TextBox"), TextBox)
那么我应该如何从gridview中的时间选择器中检索时间?
so how should i retrieve the time from the timeselector in the gridview?
<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="cc1" %>
<ItemTemplate>
<table style="width: 79%; height: 31px;">
<tr>
<td class="style1">
<asp:Label ID="Label1" runat="server" Text="Time to start:"></asp:Label>
</td>
<td>
<cc1:TimeSelector ID="TimeSelector3" runat="server" AllowSecondEditing="false" DisplaySeconds="False" Height="25px" MinuteIncrement="15" Width="150px" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</td>
</tr>
</table>
</ItemTemplate>
<ControlStyle Width="100px" />
<ItemStyle Width="210px" />
</asp:TemplateField>
推荐答案
使用与查找文本框相同的代码.然后,您必须在TimeSelector控件上具有一些保留时间的属性.
Hi,
Use the same code that you used to find text box. Then you must have some property on TimeSelector control that holds time.
看看下面的代码是否对您有用-
See if the following code works for you-
Protected Sub Button1_Click(sender As Object, e As System.EventArgs)
Dim tp As MKB.TimePicker.TimeSelector
tp = DirectCast(DirectCast(sender, _
Control).NamingContainer.FindControl("TimeSelector3"), MKB.TimePicker.TimeSelector)
Dim required As DateTime = tp.Date ' this DateTime variable has the required time component
End Sub
这篇关于如何从gridview中的TimeSelector检索时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文