I have a gridview1 and it has a normal field. 
After clicking edit link, I want to show a DropdownList that reads from my Database.
How can I achieve this?
this is my code for list template:
<asp:TemplateField HeaderText="Course Name">
     <ItemTemplate>
         <asp:Label ID="Label7" runat="server" Text='<%# Bind("CName") %>'></asp:Label>
     </ItemTemplate>
       <EditItemTemplate>
         <asp:DropDownList ID="ddlECName"  CssClass="auto-style16" Width="80px" runat="server" ></asp:DropDownList>
           </EditItemTemplate>
           <FooterTemplate>
                  <asp:DropDownList ID="ddlCName"  CssClass="auto-style16" Width="80px" runat="server" ></asp:DropDownList>
            </FooterTemplate>
 </asp:TemplateField>
for adding values in ddl :
    //This code for adding values in course name list in the edit mood
 DropDownList ddlECName = ????? as DropDownList; 
                ddlECName.DataSource = GetData("SELECT * FROM TBCourse  INNER JOIN TbCourseMajor ON  TBCourse.CId = TbCourseMajor.CId  AND TbCourseMajor.MNom='" + DLMNom.SelectedValue + "'");
                ddlECName.DataTextField = "CName";
                ddlECName.DataValueField = "CId";
                ddlECName.DataBind();
                //Add Default Item in the DropDownList
                ddlECName.Items.Insert(0, new ListItem("----"));
The question is what should I write to define ddlECName ? how to tell them that I mean the ddl that in edit mode of grid view?
The second question is where to write this in which function ? Ex: OnRowEditing...etc
I have confusion in dealing with grid view methods if you know a good explanation please give the url. thank you
 
     
     
    