I have a web form with a Listbox. When trying to read the value of the last selected item with the statement below, I always get the first item, even if the user selected another item:
lstGrants.SelectedItem.Value)
I am new to ASP.NET, so I don't know whether AutoPostback should be set to true. This is a subject that it is still not clear to me. Also, when setting Autopostback to true, there is some data transfer between client and server (if I am not wrong) that I would like to avoid.
Any suggestion would be very welcome. I am having a hard time learning ASP.NET!
Thank you very much.
Mikesounds like you are rebinding the data to the listbox on every page_load, use..
if not page.ispostback then
'bind data
end if
"Mike" <nospam@.nospam.com> wrote in message news:%23YqKKsRaEHA.2408@.tk2msftngp13.phx.gbl...
Hello,
I have a web form with a Listbox. When trying to read the value of the last selected item with the statement below, I always get the first item, even if the user selected another item:
lstGrants.SelectedItem.Value)
I am new to ASP.NET, so I don't know whether AutoPostback should be set to true. This is a subject that it is still not clear to me. Also, when setting Autopostback to true, there is some data transfer between client and server (if I am not wrong) that I would like to avoid.
Any suggestion would be very welcome. I am having a hard time learning ASP.NET!
Thank you very much.
Mike
Mike <nospam@.nospam.com> typed:
> Hello,
> I have a web form with a Listbox. When trying to read the value of
> the last selected item with the statement below, I always get the
> first item, even if the user selected another item:
> lstGrants.SelectedItem.Value)
Alternative you can use 1stGrant.SelectedValue also.
Where do you bind the ListBox ? In the load_Page method ? If yes, Do you
bind the ListBox everytime the page is loaded or only for the fist call ?
The right answer is only for the first call.
if(!IsPostBack)
{
.....bind the list box
}
> I am new to ASP.NET, so I don't know whether AutoPostback should be
> set to true. This is a subject that it is still not clear to me.
In the properties page of the control you can find this property.
> Also, when setting Autopostback to true, there is some data transfer
> between client and server (if I am not wrong) that I would like to
> avoid.
Yes sure. The post back mechanism send to the server the page content. For
more informations see this link:
http://msdn.microsoft.com/library/d...ssingstages.asp
> Any suggestion would be very welcome. I am having a hard time
> learning ASP.NET!
For a fast begin use the quickstart tutorial ;-)
http://www.asp.net/Tutorials/quickstart.aspx
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Thanks.
"Raterus" <raterus@.spam.org> wrote in message news:#rUHtzRaEHA.2844@.TK2MSFTNGP12.phx.gbl...
sounds like you are rebinding the data to the listbox on every page_load, use..
if not page.ispostback then
'bind data
end if
"Mike" <nospam@.nospam.com> wrote in message news:%23YqKKsRaEHA.2408@.tk2msftngp13.phx.gbl...
Hello,
I have a web form with a Listbox. When trying to read the value of the last selected item with the statement below, I always get the first item, even if the user selected another item:
lstGrants.SelectedItem.Value)
I am new to ASP.NET, so I don't know whether AutoPostback should be set to true. This is a subject that it is still not clear to me. Also, when setting Autopostback to true, there is some data transfer between client and server (if I am not wrong) that I would like to avoid.
Any suggestion would be very welcome. I am having a hard time learning ASP.NET!
Thank you very much.
Mike
Thanks.
"Davide Vernole [MVP]" <davide@.online.knodev.com> wrote in message news:e9I7a1RaEHA.4048@.TK2MSFTNGP10.phx.gbl...
Mike <nospam@.nospam.com> typed:
> Hello,
> I have a web form with a Listbox. When trying to read the value of
> the last selected item with the statement below, I always get the
> first item, even if the user selected another item:
> lstGrants.SelectedItem.Value)
Alternative you can use 1stGrant.SelectedValue also.
Where do you bind the ListBox ? In the load_Page method ? If yes, Do you
bind the ListBox everytime the page is loaded or only for the fist call ?
The right answer is only for the first call.
if(!IsPostBack)
{
....bind the list box
}
> I am new to ASP.NET, so I don't know whether AutoPostback should be
> set to true. This is a subject that it is still not clear to me.
In the properties page of the control you can find this property.
> Also, when setting Autopostback to true, there is some data transfer
> between client and server (if I am not wrong) that I would like to
> avoid.
Yes sure. The post back mechanism send to the server the page content. For
more informations see this link:
http://msdn.microsoft.com/library/d...ssingstages.asp
> Any suggestion would be very welcome. I am having a hard time
> learning ASP.NET!
For a fast begin use the quickstart tutorial ;-)
http://www.asp.net/Tutorials/quickstart.aspx
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
0 comments:
Post a Comment