Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 October 18th, 2005, 03:41 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default Controls

Greetings all.

I am working on an application that displays a grid with dropdownboxs in various parts of this grid. Now the entire gird is generated dynamically based on user interaction, so i have put the code required to generate this grid in an .ascx file. Here is my problem:

My grid is generating perfectly, but I am stuck on this on part: I currently have the functionality that is the user changes an item in any of the dropdowns, the form will postback to itself, however, i am unable to get the selectedIndex.Text or Value.

first let me share with you how i create the drop downboxes:
Code:
                            hwriter.WriteBeginTag("select")
                            hwriter.WriteAttribute("name", i.ToString)
                            hwriter.WriteAttribute("OnChange", "javascript: " & Page.GetPostBackEventReference(Me, Me.UniqueID))
                            hwriter.Write(HtmlTextWriter.TagRightChar)
                            hwriter.WriteBeginTag("option")
                            hwriter.WriteAttribute("value", "ins~" & intUsers(i).ToString & "~" & intLinkId.ToString & "~" & dt.Rows(x).Item("roleValue"))
                            hwriter.WriteAttribute("selected", "selected")
                            hwriter.Write(HtmlTextWriter.TagRightChar)
                            hwriter.Write(dt.Rows(x).Item("name"))
                            hwriter.WriteEndTag("option")

The way the above code is laid out, when a postback occurs, my eventArgs is the value of: 'Me.UniqueID' which does me no good. I have looked through my VS.Net help files and there are examples on how to do this with button and raising the click event, I can not duplicate this for the onChange event??? Any help as to how I can get the values of the selected item would be greatly appreciated.
-Doug

"The one language all programmers understand is profanity."
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old October 19th, 2005, 11:08 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Follow-up:
While I don't think that this is the "best" way to accomplish this I have found somewhat of a work around to solve my problem at hand.

Using the supplied code as a reference,
I changed the
Code:
Page.GetPostBackEventReference(Me, Me.UniqueID))
to
Code:
Page.GetPostBackEventReference(Me, i.toString))
when a user changes the value of a dropdown the method:

Code:
Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
And the name of the dropdownbox is passed in as an argument. From here I call a method that excepts a string as a parameter (the dropdown ID) and then use the
Code:
Request('dropdownID')
to get the values that are sent via postback.

So that is one possible solution, though if anyone has any input or thoughts that are greatly appreciated!

is called.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
Retain the value of Controls S_Dogra ASP.NET 1.0 and 1.1 Professional 1 January 31st, 2007 01:21 PM
Binding controls Boris Kofman VB Databases Basics 1 January 20th, 2007 01:16 PM
Using controls AllenJ .NET Framework 2.0 1 July 31st, 2006 05:01 AM
Controls Natalie Beginning VB 6 6 September 12th, 2003 10:27 AM





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