Reputation: 39
In my ASP.NET project I have one gridview and I have placed the DateControl in gridview using TemplateField. My question is how can I get the Selected Date value? I'm doing my code in VB
My ASP code is
<asp:TemplateField HeaderText="Release Date" ControlStyle-Width="100">
<ItemTemplate>
<uc1:DateControl ID="UCReleaseDate" runat="server" />
</ItemTemplate>
</asp:TemplateField>
And my vb code is (not working)
Dim dtReleaseDate As DateTime
dtReleaseDate = DateTime.Parse(GVMaintainBankChallon.Rows(iGVRowIndex).FindControl ("UCReleaseDate").ToString)
I want to get the Selected Date value in dtReleaseDate variable.. Hope someone will understand this problem and help me..
The gridview image is shown below.
After selecting the date.
I want this selected date to codebehind date variable.
Upvotes: 1
Views: 927
Reputation: 14614
As per comment below, DateControl
has a string property named DateValue
. Assuming that the date is in MM/dd/yyyy
format, this code should work
Dim dateFromControl As String = CType(GVMaintainBankChallon.Rows(iGVRowIndex).FindControl("UCReleaseDate"), DateControl).DateValue
Dim dtReleaseDate As DateTime
dtReleaseDate = DateTime.ParseExact(dateFromControl, "MM/dd/yyyy", Nothing)
Upvotes: 1