List Box Question

  • Thread starter Thread starter Amy Snyder
  • Start date Start date
A

Amy Snyder

I was expecting the code below to write the selected item in the list
box to the browser but nothing happens.

What I am trying to do in the grand scheme of things is change the
pagesize of a datagrid after selecting from a list box. I figured I
could do this with the SelectedIndexChanged event. Is that possible?

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Response.Write(DropDownList1.SelectedItem)
End Sub
 
DropDownList1.SelectedIte

should b

DropDownList1.SelectedItem.Text or DropDownList1.SelectedItem.Value
What I am trying to do in the grand scheme of things is change the pagesize of a datagrid after selecting from a list box. I figured I could do this with the SelectedIndexChanged event. Is that possible

Yes. You can set the page size property of the datagrid inside the SelectedIndexChanged event handler method

HTH
Suresh

----- Amy Snyder wrote: ----

I was expecting the code below to write the selected item in the lis
box to the browser but nothing happens.

What I am trying to do in the grand scheme of things is change th
pagesize of a datagrid after selecting from a list box. I figured
could do this with the SelectedIndexChanged event. Is that possible

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender A
System.Object, ByVal e As System.EventArgs) Handle
DropDownList1.SelectedIndexChange
Response.Write(DropDownList1.SelectedItem
End Su



*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
 
DropDownList1.SelectedItem.Value

Or you could just do
DropDownList1.SelectedValue

There shouldn't be any problem getting what you are after to work. What I'd
do is in the dropdown, make the indexes the number you are after to change
the datagrid's size, then in the selectedindexchanged event do something
like

myDatagrid.pagesize = DropDownList1.SelectedValue
 
That doesn't work. If I add a submit button, it works.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write(DropDownList1.SelectedItem.Value)
End Sub
 
Ensure you have set AutoPostback="True" for you Dropdownlist control

(i.e
<asp:DropDownList id="ddlTest" runat="server" AutoPostBack="True"></asp:DropDownList

----- Amy Snyder wrote: ----

That doesn't work. If I add a submit button, it works.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e A
System.EventArgs) Handles Button1.Clic
Response.Write(DropDownList1.SelectedItem.Value
End Su


*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
 
Back
Top