dropdownlist within a datagrid - programatically setting the selectedindex when page loads and after an update button pressed

Hi,

I am sure this is done all the time, but I am relatively new to ASP.NET (PLEASE NOTE: project also contains considerable VB.NET - I'd rather have as little on the HTML page and as much code in the .vb files as possible).

We have 3 drop down list's within a datagrid each with different information in them.
All rows within the datagrid are editable.
At the moment it is a static number of rows (15).

What I need to be able to do, is when we load from a table into the grid (binding a dataset) and load from another table into the combo boxes using DataSource="<%# BindCostCentre() %>" on the HTML page (where bindcostcentre code in .vb returns Return cmdCommand.ExecuteReader(CommandBehavior.CloseConnection)) the lists need to be set to a default (based on a value I can retrieve in the database).

EG the list might contain:
Project A
Project B
Project C
Project D
Each row loads from the database via code in the .vb which is already written and working, however the combo box is always defaulting to the first list item, I need it to point to different items depending on which row it is on.
EG
Row 1's drop down needs to point to Project C
Row 2's drop down needs to point to Project B

Basically I need to assign selectedindex on a per row basis on page load/bind for the combo boxes.

Hope this isn't too confusing, but please ask questions if it is.
Thanks for your help,
Brian.
LVL 5
brianb99999Asked:
Who is Participating?
 
sachiekConnect With a Mentor Commented:
You can set to particular listitem in dropdown list in datagrid's ItemDatabound event by findind particular dropdown controls using find control method.

Sachi
0
 
brianb99999Author Commented:
Sachi your a Saint  - thanks

Brian.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.