where did the methods for a component go???

A

Adam Sandler

Hello,

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/...mples/ctrlref/standard/calendar/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!
 
A

Adam Sandler

Hi all,

A week ago, I tried something like this to get access to a calendar's
methods 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 confused as
to 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(AddressOf 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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top