Using VWD 2005 here... I have a GridView and for usability, the edit
template for one of the columns was changed from the defaut to a
calendar control.
Also, I have some content which I want to add to the calendar...
something akin to this MSDN example...
http://www.asp.net/QuickStart/util/...r/Calendar5.src
On the code behind page, where the class and method name comboboxes
are, the calendar and it's methods isn't there! What happened to the
component and its methods? To put custom content in the calendar, like
the example, the DayRender method is needed.
Suggestions are greatly appreciated.
Thanks!Hi all,
A w
ago, I tried something like this to get access to a calendar'smethods which are part of the edit item template in my gridview:
Dim WithEvents myCalendar As New Calendar
Protected Sub GridView1_RowDataBound(ByVal sender As Object,
ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
myCalendar =
Me.GridView1.Rows(myRow).FindControl("Calendar1")
AddHandler calView.DayRender, AddressOf
calView_DayRender
End If
End Sub
This fails miserably with a null reference exception. I'm
asto why it's looking for the new keyword here... is that for the event
handler then?
So after some more reading, I tried this...
'
'
'
Protected Sub GridView1_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles
GridView1.Load
Dim editField As New TemplateField
editField.EditItemTemplate = New
CompiledBindableTemplateBuilder(AddressO
f buildCalendar, Nothing)
GridView1.Columns.Insert(3, editField)
End Sub
'
'
'
Sub buildCalendar(ByVal ctl As Control)
Dim ipa As IParserAccessor = ctl
Dim cal As Calendar = New Calendar
cal.TemplateControl = Me
cal.ID = "editCalendar"
AddHandler cal.DayRender, AddressOf renderCalendar
ipa.AddParsedSubObject(cal)
End Sub
'
'
'
Sub renderCalendar(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs)
Dim myCal As Calendar = CType(sender, Calendar)
myCal.ID = "editCalendar"
'
' stuff which follows would be for the calendar cell
background color and text rendering one can do in
' DayRender...
'
End Sub
This solution does indeed make an edit item template with a calendar as
the component... but there are two problems...
1. I want the edit item to be a part of column 3. But what this thing
does is create a totally new column at runtime, inserts it, and shifts
the other columns one index to the right.
2. When a user clicks a day an additional, blank, column is added to
the grid.
Can anyone help with the 2 problems I still have? Thanks!
0 comments:
Post a Comment