Link to home
Start Free TrialLog in
Avatar of dolbs
dolbs

asked on

How do I preselect the current database value in a populated datagrid dropdown list when in edit mode.

First off thanks to Rafayali for his code which I am using.  
I have a editable datagrid incorporating a dropdownlist pouplated with data from the database. The function in the attached code sippet is part of the edit template which populates the dropdownlist. (thanks again Rafayali).  The problem is I cannot manage to select the current cell value in the dropdownlist so that the user sees the currently stored database value selected in the dropdownlist.  I have tried many searched solutions but so far not able to find one that works.  Can someone please help me out (VB code would be great as my C insn't great)  Thank you all.

<EditItemTemplate>
<asp:DropDownList
ID="DDLPI"
AutopostBack = "False"
Runat="server"
DataTextField = "NameInitial"
DataValueField = "ID"
Datasource='<%# BindDDL2()%>'/>
</asp:DropdownList>
</EditItemTemplate>
</asp:TemplateColumn>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dolbs
dolbs

ASKER

Thanks.  Easy answer that I should have thought of myself.  Great service and reply.