Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2004, 03:30 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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
  #2 (permalink)  
Old March 8th, 2004, 03:52 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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.

  #3 (permalink)  
Old March 10th, 2004, 03:04 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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.)
  #4 (permalink)  
Old March 12th, 2004, 11:01 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:59 PM.


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