Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropdownList in EditTemplate

Reply
Thread Tools

DropdownList in EditTemplate

 
 
Yan Wang
Guest
Posts: n/a
 
      05-23-2004
I can populate the dropdown box in a edittemplate correctly. I can even
have the dropdown preselect the correct value returned from my
database. However, I cannot capture the selected value when I edit the
column. It always updated the column to the first item in the list
regardless of
what I select when it is in edit mode. Anyone has the same problem?

Thanks a lot!



 
Reply With Quote
 
 
 
 
Jos
Guest
Posts: n/a
 
      05-23-2004
Yan Wang wrote:
> I can populate the dropdown box in a edittemplate correctly. I can
> even have the dropdown preselect the correct value returned from my
> database. However, I cannot capture the selected value when I edit the
> column. It always updated the column to the first item in the list
> regardless of
> what I select when it is in edit mode. Anyone has the same problem?
>
> Thanks a lot!


On postback, make sure the datagrid or datalist is re-created in the
same way, with the same dropdown lists present (a control can
not restore its state when it's not there anymore).
This means that you need to databind the grid on postback too
(you can do this in Page_Load). Don't preselect the correct value
this time, the value will be restored from the postback automatically.

Then you can handle the postback (probably in the "UpdateCommand"
event).

Finally, you may bind the datagrid or list again, depending on what
you want to show after postback.

--

Jos


 
Reply With Quote
 
 
 
 
Natty Gur
Guest
Posts: n/a
 
      05-24-2004
Hi,


Ensure that you dont refill your grid on postback. you can use page
ispostback to determine if your page called for the first time or its
postback call.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377


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

 
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
problem with populating a dropdownlist in editTemplate of detailsview Jan ASP .Net 2 08-12-2007 10:52 AM
Formview EditTemplate Dropdownlist Joe Reiss ASP .Net Web Controls 0 02-20-2007 02:34 PM
Update SqlDataSource with value of DropDownList in EditTemplate on GridView ES ASP .Net Web Controls 0 06-16-2006 10:24 PM
Textbox value in the edittemplate of a datalist doesn't report the changes Antonio D'Ottavio ASP .Net 2 09-26-2005 03:26 PM
EditTemplate - Dropdownlist Krish ASP .Net 0 09-21-2005 03:22 PM



Advertisments