Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

Reply
Thread Tools

All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

 
 
Josh Behl
Guest
Posts: n/a
 
      10-28-2003
I've got my datagrid working to the point where I can edit records and even
pick different values in my dropdownlists, save the record and have that
data committed to the table. The problem I am having is that when I go into
edit a record each of my picklist values get reset to the first value in the
list.


How can I fix this??

Josh Behl


 
Reply With Quote
 
 
 
 
cfaul
Guest
Posts: n/a
 
      10-28-2003
"Josh Behl" <(E-Mail Removed)> wrote in message news:<#$(E-Mail Removed)>...
> I've got my datagrid working to the point where I can edit records and even
> pick different values in my dropdownlists, save the record and have that
> data committed to the table. The problem I am having is that when I go into
> edit a record each of my picklist values get reset to the first value in the
> list.
>
>
> How can I fix this??
>
> Josh Behl


Hi Josh

This is possibly happening because you dont have an 'isPostBack'
condition in your page_load sub. When you push the button to execute,
the page_load sub is called and your dropdownlists will be populated
again, using the first value of the list as the 'selected value'. This
can be fixed by putting the initial page loading code inside the
following if statement:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then
'Populate dropdownlist
End If

End Sub

Good luck
 
Reply With Quote
 
 
 
 
Josh Behl
Guest
Posts: n/a
 
      10-28-2003
I am currently populating my drop down lists with a collection of values
which I enter in the html code itself:
<aspropDownList id=ddlFee runat="server" Width="80px"
DataMember="OptionRequestCRM" DataSource="" DataTextField="Fee"
DataValueField="OptionID">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp....etc...

Since I am populating my drop down this way, is there another solution????


"cfaul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Josh Behl" <(E-Mail Removed)> wrote in message

news:<#$(E-Mail Removed)>...
> > I've got my datagrid working to the point where I can edit records and

even
> > pick different values in my dropdownlists, save the record and have that
> > data committed to the table. The problem I am having is that when I go

into
> > edit a record each of my picklist values get reset to the first value in

the
> > list.
> >
> >
> > How can I fix this??
> >
> > Josh Behl

>
> Hi Josh
>
> This is possibly happening because you dont have an 'isPostBack'
> condition in your page_load sub. When you push the button to execute,
> the page_load sub is called and your dropdownlists will be populated
> again, using the first value of the list as the 'selected value'. This
> can be fixed by putting the initial page loading code inside the
> following if statement:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> If Not IsPostBack Then
> 'Populate dropdownlist
> End If
>
> End Sub
>
> Good luck



 
Reply With Quote
 
Imtiaz Hussain
Guest
Posts: n/a
 
      10-29-2003
You can databind the dropdownlist in the code behind file as well.
As charlene mentioned the data might be getting repopulated on postback.
You might want to prevent the datagrid that contains the dropdownlist from
rebinding on postback.

Hope this helps.
Imtiaz Hussain

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1st Drop-down selection determins selected value in all drop-downs In ASP.Net Wizard jaysch ASP .Net 0 04-30-2011 02:19 PM
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Enable second drop down after first drop down is selected teser3@hotmail.com Javascript 0 01-28-2009 12:59 AM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments