I have 3 tables,
DataGridView and DropDownList
TABLES:
tblACTIONS: ID, UnitID, etc
tblUNITS: UnitID, UnitName, LocationID
tblLOCATIONS: LocationID, Location
This is how I populate the grid
SELECT tblACTIONS.ID, tblUNITS.UnitName & ' - ' & tblLOCATIONS.Location
AS XYZ,
FROM (((tblACTIONS INNER JOIN tblUNITS ON tblACTIONS.UnitID = tblUNITS.UnitID)
INNER JOIN tblLOCATIONS ON tblUNITS.LocationID = tblLOCATIONS.LocationID)
This is how I populate the Dropdown (ID1 – valuemem; XYZ –displaymem)
SELECT tblUNITS.UnitID AS ID1, tblUNITS.UnitName & ' - ' & tblLOCATIONS.Location
AS XYZ
FROM tblUNITS INNER JOIN tblLOCATIONS ON tblUNITS.LocationID = tblLOCATIONS.LocationID
I'd like to click on the grid's row and to set the dropdownlist text
ddUnit.Text = dGr.Rows[e.RowIndex].Cells["XYZ"].Value.ToString();
But it doesn't work - the dropdownlist still has first blank unselected text. Can anybody point me to a solution (please)?
Problem with DropDownList
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Elmar12 reputationPosted May 26, 2013, 8:50 PM EDT
Pankaj PandeyRank #642 · 3.7K reputationPosted May 26, 2013, 9:00 PM EDT
try after write the code in Page.IsPostback.
if(!Page.IsPostback())
{
write your code
}