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">
            <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:Label ID="Label6" runat="server" Text='<%# Bind("MESig") %>'></asp:Label>
            <ItemStyle Width="60px" />

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is how I would that you do't have to make database call for filling the dropdownlist for every single row.

1. Create a dropdownlist (ex. drpDummy) on your aspx page outside the gridview and bind it to the "SelectMEName" datasource. Make it invisible.
2. I
3. Inside of the gridview's rowDataBound event, do the following:
 If e.Row.RowType = DataControlRowType.DataRow Then

                   Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)

                    'Create Drop down list for name
                        Dim ddl As DropDownList = CType(e.Row.FindControl("edMESigDropdownlist"), DropDownList)
                        ddl.DataSource = drpDummy.Items
                        ddl.DataTextField = "Text"
                        ddl.DataValueField = "Value"
                        If Not IsDBNull(rowView("TheNameYouWant")) Then
                            ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText(CStr(rowView("Status"))))
                        End If
End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lakhiAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.