.NETGURU
DropDownList
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.


Kladiva, Jay
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
    boundary="----_=_NextPart_001_01C21C5B.F47ED670"

------_=_NextPart_001_01C21C5B.F47ED670
Content-Type: text/plain;
    charset="iso-8859-1"

I have a DropDownList and I what to set the selected item when a user
returns. When I step through the code, the SelectedItem.Value is changed to
the value I pass in from the QueryString which matches the value of one of
the items in the list, but when the page renders nothing is selected. Any
ideas?

Dim dtb As New DataTable()

'Code to get valid DataTable with rows

ddlLevel.DataSource = dtb

ddlLevel.DataTextField = "LevelDesc"

ddlLevel.DataValueField = "SearchLevelKey"

ddlLevel.DataBind()

If Request.QueryString("mode") = "edit" Then

ddlLevel.SelectedItem.Value = Request.QueryString("levelid")

End If

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 4:34 PM
To: aspngvb
Subject: [aspngvb] RE: even handling in VB.NET vs. C#

Never mind; got the answer thanks. The answer is yes, VB creates the
delegate and check before invoking.

-j

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 3:16 PM
To: aspngvb
Subject: [aspngvb] even handling in VB.NET vs. C#

I notice that in C# when you want to raise an event you test that the event
has a handler registered, and then you call the handler directly,

if (ClickApply != null)
ClickApply(this, new EventArgs());

In VB.NET you do no test, but you call RaiseEvent ClickApply(this, new
EventArgs());

Am I right that VB.NET is doing the test for you (hidden somewhere) or is
the mechanism just different?

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

| [aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

| [aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

------_=_NextPart_001_01C21C5B.F47ED670
Content-Type: text/html;
    charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff>
<P><FONT face=Arial size=2><SPAN class=007561815-25062002>I have a DropDownList
and I what to set the selected item when a user returns.  When I step
through the code, the SelectedItem.Value is changed to the value I pass in from
the QueryString which matches the value of one of the items in the
list, but when the page renders nothing is selected.  Any
ideas?</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN
class=007561815-25062002> </SPAN></FONT><FONT face=Arial
size=2>Dim</FONT><FONT size=2><FONT face=Arial><FONT color=#000000> dtb
</FONT><FONT color=#0000ff>As</FONT><FONT color=#000000> </FONT><FONT
color=#0000ff>New</FONT></FONT><FONT face=Arial color=#000000>
DataTable()</FONT></FONT></P>
<P><SPAN class=007561815-25062002><FONT face=Arial
size=2></FONT></SPAN> </P>
<P><SPAN class=007561815-25062002><FONT face=Arial size=2>'Code to get valid
DataTable with rows</FONT></SPAN></P>
<P><FONT face=Arial size=2></FONT> </P>
<P><FONT face=Arial size=2>ddlLevel.DataSource = dtb</FONT></P>
<P><FONT face=Arial size=2>ddlLevel.DataTextField = "LevelDesc"</FONT></P>
<P><FONT face=Arial size=2>ddlLevel.DataValueField = "SearchLevelKey"</FONT></P>
<P><FONT face=Arial size=2>ddlLevel.DataBind()</FONT></P>
<P><FONT face=Arial><FONT size=2>If Request.QueryString("mode") = "edit"
Then</FONT></P></FONT>
<P><FONT face=Arial><FONT size=2><SPAN
class=007561815-25062002>    </SPAN>ddlLevel.SelectedItem.Value =
Request.QueryString("levelid")</FONT></FONT></P>
<P><FONT face=Arial size=2>End If</FONT></P>
<P><FONT face=Arial size=2></FONT> </P>
<P><FONT size=2><FONT face=Arial> </P></FONT></FONT></FONT></DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Jesse Liberty
[mailto:Click here to reveal e-mail address]<BR><B>Sent:</B> Friday, March 22, 2002
4:34 PM<BR><B>To:</B> aspngvb<BR><B>Subject:</B> [aspngvb] RE: even handling
in VB.NET vs. C#<BR><BR></FONT></DIV>
<DIV><SPAN class=560243222-22032002><FONT face=Arial color=#0000ff
size=2>Never mind; got the answer thanks. The answer is yes, VB creates the
delegate and check before invoking.</FONT></SPAN></DIV>
<DIV><SPAN class=560243222-22032002><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=560243222-22032002><FONT face=Arial color=#0000ff
size=2>-j</FONT></SPAN></DIV>
<DIV> </DIV>
<P><FONT size=2>-------------------------------<BR>Jesse Liberty<BR>Liberty
Associates, Inc.<BR></FONT><FONT size=2>.NET Training & Development<BR><A
href="http://www.libertyassociates.com/"" target="_blank">http://www.libertyassociates.com/";
target=_blank>http://www.LibertyAssociates.com</A></FONT> </P>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Jesse Liberty
[mailto:Click here to reveal e-mail address]<BR><B>Sent:</B> Friday, March 22,
2002 3:16 PM<BR><B>To:</B> aspngvb<BR><B>Subject:</B> [aspngvb] even
handling in VB.NET vs. C#<BR><BR></FONT></DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial size=2>I notice that in
C# when you want to raise an event you test that the event has a handler
registered, and then you call the handler directly,</FONT></SPAN></DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial size=2>if (ClickApply
!= null)<BR>     ClickApply(this, new
EventArgs());</FONT></SPAN></DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial size=2>In VB.NET you do
no test, but you call RaiseEvent ClickApply(this, new
EventArgs());</FONT></SPAN></DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial size=2>Am I right that
VB.NET is doing the test for you (hidden somewhere) or is the mechanism just
different?</FONT></SPAN></DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=684351320-22032002><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<P><FONT size=2>-------------------------------<BR>Jesse Liberty<BR>Liberty
Associates, Inc.<BR></FONT><FONT size=2>.NET Training &
Development<BR><A href="http://www.libertyassociates.com/"" target="_blank">http://www.libertyassociates.com/";
target=_blank>http://www.LibertyAssociates.com</A></FONT> </P>
<DIV> </DIV>| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT </BLOCKQUOTE>|
[aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT
</BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C21C5B.F47ED670--

--------------InterScan_NT_MIME_Boundary--

Reply to this message...
 
    
Andy Smith
what you are doing is changing the value of the selected item. instead find the item with that value and make it selected
for instance
ddlLevel.SelectedIndex = ddlLevel.Items.IndexOf( ddlLevel.Items.FindByValue( Request.QueryString("levelid") )

personally, I believe they should have written a SelectByValue method and a SelectByText method, but hey, you could always subclass.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

-----Original Message-----
From: Kladiva, Jay [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 25, 2002 9:21 AM
To: aspngvb
Subject: [aspngvb] DropDownList

I have a DropDownList and I what to set the selected item when a user returns. When I step through the code, the SelectedItem.Value is changed to the value I pass in from the QueryString which matches the value of one of the items in the list, but when the page renders nothing is selected. Any ideas?

Dim dtb As New DataTable()

'Code to get valid DataTable with rows

ddlLevel.DataSource = dtb

ddlLevel.DataTextField = "LevelDesc"

ddlLevel.DataValueField = "SearchLevelKey"

ddlLevel.DataBind()

If Request.QueryString("mode") = "edit" Then

ddlLevel.SelectedItem.Value = Request.QueryString("levelid")

End If

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 4:34 PM
To: aspngvb
Subject: [aspngvb] RE: even handling in VB.NET vs. C#

Never mind; got the answer thanks. The answer is yes, VB creates the delegate and check before invoking.

-j

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 3:16 PM
To: aspngvb
Subject: [aspngvb] even handling in VB.NET vs. C#

I notice that in C# when you want to raise an event you test that the event has a handler registered, and then you call the handler directly,

if (ClickApply != null)
ClickApply(this, new EventArgs());

In VB.NET you do no test, but you call RaiseEvent ClickApply(this, new EventArgs());

Am I right that VB.NET is doing the test for you (hidden somewhere) or is the mechanism just different?

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

| [aspngvb] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

| [aspngvb] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT
Reply to this message...
 
    
Jaison Green
myDropDownList.Items.FindByValue(Request.QueryString["levelid"]).Selecte
d = true;

Jaison Green
Hunt Interactive
425*746*7880

-----Original Message-----
From: Kladiva, Jay [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 25, 2002 8:21 AM
To: aspngvb
Subject: [aspngvb] DropDownList

I have a DropDownList and I what to set the selected item when a user
returns. When I step through the code, the SelectedItem.Value is
changed to the value I pass in from the QueryString which matches the
value of one of the items in the list, but when the page renders nothing
is selected. Any ideas?

Dim dtb As New DataTable()

'Code to get valid DataTable with rows

ddlLevel.DataSource = dtb

ddlLevel.DataTextField = "LevelDesc"

ddlLevel.DataValueField = "SearchLevelKey"

ddlLevel.DataBind()

If Request.QueryString("mode") = "edit" Then

ddlLevel.SelectedItem.Value = Request.QueryString("levelid")

End If

    -----Original Message-----
    From: Jesse Liberty [mailto:Click here to reveal e-mail address]
    Sent: Friday, March 22, 2002 4:34 PM
    To: aspngvb
    Subject: [aspngvb] RE: even handling in VB.NET vs. C#


    Never mind; got the answer thanks. The answer is yes, VB creates
the delegate and check before invoking.
    
    -j
    

    -------------------------------
    Jesse Liberty
    Liberty Associates, Inc.
    .NET Training & Development
    http://www.LibertyAssociates.com
<http://www.libertyassociates.com/>

        -----Original Message-----
        From: Jesse Liberty
[mailto:Click here to reveal e-mail address]
        Sent: Friday, March 22, 2002 3:16 PM
        To: aspngvb
        Subject: [aspngvb] even handling in VB.NET vs. C#
    
    
        I notice that in C# when you want to raise an event you
test that the event has a handler registered, and then you call the
handler directly,
        
        if (ClickApply != null)
         ClickApply(this, new EventArgs());
        
        In VB.NET you do no test, but you call RaiseEvent
ClickApply(this, new EventArgs());
        
        Am I right that VB.NET is doing the test for you (hidden
somewhere) or is the mechanism just different?
        
        

        -------------------------------
        Jesse Liberty
        Liberty Associates, Inc.
        .NET Training & Development
        http://www.LibertyAssociates.com
<http://www.libertyassociates.com/>

        
        | [aspngvb] member Click here to reveal e-mail address = YOUR
ID | http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

    | [aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT
Reply to this message...
 
    
Carlos Magalhaes
This is a work around first what you should do is a response.write or
trace.write to see if the value is actually being passed back to the pages
and/or control!

If it is you can set that value to be the first value in your index use this
code

mydropdown.Items.Insert(0, '" & leveled & "')

That should do it but first do yourself a favor and check if he value is
being passed back first!

HTH

Carlos

-----Original Message-----
From: Kladiva, Jay [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 25, 2002 5:21 PM
To: aspngvb
Subject: [aspngvb] DropDownList

I have a DropDownList and I what to set the selected item when a user
returns. When I step through the code, the SelectedItem.Value is changed to
the value I pass in from the QueryString which matches the value of one of
the items in the list, but when the page renders nothing is selected. Any
ideas?

Dim dtb As New DataTable()

'Code to get valid DataTable with rows

ddlLevel.DataSource = dtb

ddlLevel.DataTextField = "LevelDesc"

ddlLevel.DataValueField = "SearchLevelKey"

ddlLevel.DataBind()

If Request.QueryString("mode") = "edit" Then

ddlLevel.SelectedItem.Value = Request.QueryString("levelid")

End If

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 4:34 PM
To: aspngvb
Subject: [aspngvb] RE: even handling in VB.NET vs. C#

Never mind; got the answer thanks. The answer is yes, VB creates the
delegate and check before invoking.

-j

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

-----Original Message-----
From: Jesse Liberty [mailto:Click here to reveal e-mail address]
Sent: Friday, March 22, 2002 3:16 PM
To: aspngvb
Subject: [aspngvb] even handling in VB.NET vs. C#

I notice that in C# when you want to raise an event you test that the event
has a handler registered, and then you call the handler directly,

if (ClickApply != null)
ClickApply(this, new EventArgs());

In VB.NET you do no test, but you call RaiseEvent ClickApply(this, new
EventArgs());

Am I right that VB.NET is doing the test for you (hidden somewhere) or is
the mechanism just different?

-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com <http://www.libertyassociates.com/>

| [aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

| [aspngvb] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.

Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.

If you have received this email in error please notify
Click here to reveal e-mail address For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
Reply to this message...
 
 
System.Data.DataTable
System.EventArgs
System.Web.UI.WebControls.DropDownList




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification