Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2004, 03:30 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default Template Columns in DataGrids

This message is really for Peter, it is something he helped me with before.

Peter, if you remember, I asked you about template columns in data grids (you can see the previous thread we had). I have a RadioButtonList in a template column in a datagrid. What I wanted to do is trigger an event on the index change of the radiobutton list and get the value. I had it worked out, and lost the code unfortunately, and now I am having problems again. This is what I have so far:



    Public Sub RBLSelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = "Whoo Hooo"
    End Sub

    Public Sub CreateEvents(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim objRadioList As RadioButtonList = CType(sender, RadioButtonList)
        Dim objDataGridItem As DataGridItem = CType(objradiolist.Parent.Parent,DataGridItem)

        objRadioList = CType(dg1.FindControl("rblTest"), RadioButtonList)
        If Not objRadioList Is Nothing Then
            AddHandler objRadioList.SelectedIndexChanged, AddressOf RBLSelectionChanged
        End If


        'Gets the datagrid row index of this item:
        ' objDataGridItem.ItemIndex()

        'Gets you the value from the first column:
        Label1.Text = objDataGridItem.Cells(0).Text()


the problem is that I am getting an INVALID CAST on the radiobuttonlist declaration"
Dim objRadioList As RadioButtonList = CType(sender, RadioButtonList)

Any idea why, what did I do wrong or miss??

Thanks again for all of your help,

Jim
 
Old March 8th, 2004, 03:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I have changed my code to this:

        Dim objradiolist As New RadioButtonList()
        objradiolist = CType(dg1.FindControl("rblTest"), RadioButtonList)

        If Not objradiolist Is Nothing Then
            Dim objDataGridItem As DataGridItem = CType(objradiolist.Parent.Parent, DataGridItem)
            AddHandler objradiolist.SelectedIndexChanged, AddressOf RBLSelectionChanged
        End If

The problem now is that the FindControl method always returns NOTHING.

 
Old March 10th, 2004, 03:04 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is calling the CreateEvents() method?

One thing you might try is putting "RBLSelectionChanged" directly in the radio button list control in the markup. Try working around having to manually add the handler for the radio button list and see if that helps at all.

(Sorry for the slow response... I have been very busy lately.)
 
Old March 12th, 2004, 11:01 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

nOT A PROBLEM.... I will try your idea and see what happens.....






Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering Template columns in Detailsview shashipandey ASP.NET 2.0 Professional 0 September 20th, 2007 04:58 AM
getting values from template columns itemtemplate Laxmikant_it ASP.NET 1.0 and 1.1 Professional 4 February 6th, 2007 04:19 PM
Need to get value of gridview template columns for kmh030 ASP.NET 2.0 Professional 1 January 6th, 2007 11:10 PM
Template Columns in a Datagrid Greg Griffiths ASP.NET 1.0 and 1.1 Basics 1 October 28th, 2004 08:02 AM
Template Columns in DataGrids jbenson001 ASP.NET 1.x and 2.0 Application Design 19 September 19th, 2004 08:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.