Click here to Skip to main content
15,880,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,

I have a gridview that I bind its source manually from sql server using vb

The problem that i have a field Date in this gridview, I need to insert in it a calender so that users are obliged to enter a certain Date format.

The problem is that I am not able to neither bind data in this calender nor getting the selected date from it.

could anybody help.

Thank you
Posted

I need the page to refresh after I callthe javascript function, how this could be done, this is the piece of code, at the end of this function i ma calling javascript, how could i refresh the page after then

Protected Sub Grid(ByVal sender As Object, ByVal e As System.EventArgs)

Dim str_select As String
Dim Bln_Insert As Boolean

Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)

Dim index As Integer = gvRow.RowIndex


Dim AgentID As String = DirectCast(GridAgent.DataKeys(index).Value, String)

'UserMsgBox(index.toString())

'UserMsgBox(Calendar2.Attributes.Item("Calendar2"))

Dim S As String = Trim(CType(GridAgent.Rows(index).FindControl("valid_to"), TextBox).Text)
Dim t1 As String = GridAgent.Rows(index).FindControl("valid_to").ClientID

Dim l_Control As Control = GridAgent.Rows(index).FindControl("lbtnCalendar1")
Dim l_Control1 As Control = GridAgent.Rows(index).FindControl("lbtnCalendar1")
'DirectCast(l_Control1, TextBox).Attributes(onclick(), "alert('jjj')")

'alert("please click on the calender to choose a date")
DirectCast(l_Control, HyperLink).NavigateUrl = "javascript:show_calendar('" & t1 & "')"
End Sub
 
Share this answer
 
Javascript Calender

Put a Textbox and an Image control inside the template column.
bind your text box with your datefield, and fill the data, format the date as required while binding.

in row_databinding event find your image control from template column and add the javascript's popup opening functions for their on click event, pass clientID of relevant textbox to the javascript function.

be carefull for javascript calenders, fully verify for browser compatibility, you will find a lot from google.
 
Share this answer
 
Comments
nourbt 25-Oct-11 9:14am    
Thank you, I will try
nourbt 25-Oct-11 18:03pm    
HI again, I need more help, most of the calenders are in html with js code
Pandya Anil 25-Oct-11 23:23pm    
download javascript files from any website where you like javascript calender (files paths whould be there in page header, check page source). check source of the page and find out how the popup opening function is attached with button...
generally javascript calenders come up within 1 or 2 javascript files and a opening function
nourbt 26-Oct-11 6:47am    
I need the page to refresh after I callthe javascript function, how this could be done, this is the piece of code, at the end of this function i ma calling javascript, how could i refresh the page after then

Protected Sub Grid(ByVal sender As Object, ByVal e As System.EventArgs)

Dim str_select As String
Dim Bln_Insert As Boolean

Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)

Dim index As Integer = gvRow.RowIndex


Dim AgentID As String = DirectCast(GridAgent.DataKeys(index).Value, String)

'UserMsgBox(index.toString())

'UserMsgBox(Calendar2.Attributes.Item("Calendar2"))

Dim S As String = Trim(CType(GridAgent.Rows(index).FindControl("valid_to"), TextBox).Text)
Dim t1 As String = GridAgent.Rows(index).FindControl("valid_to").ClientID

Dim l_Control As Control = GridAgent.Rows(index).FindControl("lbtnCalendar1")
Dim l_Control1 As Control = GridAgent.Rows(index).FindControl("lbtnCalendar1")
'DirectCast(l_Control1, TextBox).Attributes(onclick(), "alert('jjj')")

'alert("please click on the calender to choose a date")
DirectCast(l_Control, HyperLink).NavigateUrl = "javascript:show_calendar('" & t1 & "')"
End Sub

Thank you Pandy

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