Link to home
Start Free TrialLog in
Avatar of lakhi
lakhi

asked on

Set value in Gridview Dropdownlist for Edit

In my gridview, there are three dropdownlists that appear when the gridview is in edit mode. Each has a textbox associated with it. When the user selects a name, the textbox is populated with the name selected.
When the data is loaded into the dropdown, the value is set to "Select Name".
What I would like to do is this: if a name already exists in the database, I'd like to bind the dropdown to it instead of "Select Name". I'm using a different sqldatasource to select the group of names that need to be in each dropdown.
Alternatively, I could just set the visible property of the dropdown to false if there is already a name in the database.
How can I do this?
I'm posting the source code for the template field.
Thanks for any help
<asp:TemplateField HeaderText="ME" SortExpression="MESig">
            <EditItemTemplate>
            <asp:TextBox runat="server" ID="edMESigTextBox" Text='<%# Bind("MESIG") %>'  ReadOnly="true" Width="100px" SkinID="InsertTB" AutoPostBack="true" />
            <asp:DropDownList runat="server" ID="edMESigDropdownlist" SkinID="DDLInsert2" OnSelectedIndexChanged="changeMETextBox" Width="120px" 
             AutoPostBack="True" DataSourceID="SelectMEName" AppendDataBoundItems="true" DataTextField="FNameLName" DataValueField="FNameLName">            
              <asp:ListItem Text="Select ME Name" Value="" />
            </asp:DropDownList>             
            </EditItemTemplate>
            <ItemTemplate>
              <asp:Label ID="Label6" runat="server" Text='<%# Bind("MESig") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle Width="60px" />
          </asp:TemplateField>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of meetingexpectations
meetingexpectations

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 lakhi
lakhi

ASKER

Please don't close. I was pulled off of this to work on another problem and should be able to get back to it tomorrow.
Thx