dropdownlist within a datagrid - programatically setting the selectedindex when page loads and after an update button pressed
Posted on 2005-04-06
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:
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.
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,