Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
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
VB
Dim rbSelect As TextBox = DirectCast(GridView2.Cells(1).FindControl("TextBox"), TextBox)


so how should i retrieve the time from the timeselector in the gridview?
HTML
<%@ Register Assembly="TimePicker" Namespace="MKB.TimePicker" TagPrefix="cc1" %>

ASP.NET
 <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>
Posted

Hi,
Use the same code that you used to find text box. Then you must have some property on TimeSelector control that holds time.
 
Share this answer
 
See if the following code works for you-
VB
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900