简体   繁体   English

如何在ASP.Net C#中的GridView的EditMode中显示DropdownList?

[英]How to show DropdownList in EditMode of GridView in ASP.Net C#?

I have a gridview1 and it has a normal field. 我有一个gridview1,它有一个正常的领域。 After clicking edit link, I want to show a DropdownList that reads from my Database. 单击编辑链接后,我想显示一个从数据库读取的DropdownList 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 : 用于在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 ? 问题是我应该写什么来定义ddlECName? how to tell them that I mean the ddl that in edit mode of grid view? 如何告诉他们我的意思是在网格视图的编辑模式下的ddl?

The second question is where to write this in which function ? 第二个问题是在哪个函数中将此写在哪里? Ex: OnRowEditing...etc 例如:OnRowEditing ...等

I have confusion in dealing with grid view methods if you know a good explanation please give the url. 如果您知道很好的解释,请在提供URL的同时处理网格视图方法时感到困惑。 thank you 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在gridview Editmode ASP.NET C#中自动发布当前日期 - Automatically post current date in gridview Editmode ASP.NET C# C#Asp.Net使用DropDownList更改GridView的数据源 - C# Asp.Net changing DataSource for GridView using DropDownList DropDownList在gridview asp.net C#中的第二次尝试时刷新 - DropDownList refresh on second attempt in gridview asp.net c# C#/ASP.NET gridview 数据绑定下拉列表索引已更改 - C#/ASP.NET gridview databind dropdownlist index changed C#-ASP.NET-GridView中的DropDownList-SelectedValue错误 - C# - ASP.NET - DropDownList in GridView - SelectedValue error 如何在ASP.NET C#WebForm中的文本框和下拉列表的GridView页脚行中获取值 - How Can I get the value in the gridview footer row of textbox and dropdownlist in asp.net c# webform 如何使用C#将数据源分配给gridview ASP.net中的转发器内的下拉列表 - how to assign a datasource to a dropdownlist inside a repeater in a gridview ASP.net with C# GridView中的DropDownList绑定到ASP.NET C#中GridView内TextBox中DropDown的选定值 - DropDownList in a GridView to bind the selected value of DropDown in TextBox inside a GridView in asp.net c# Gridview带有来自数据库的下拉列表,并在gridview外部添加,编辑删除按钮? ASP.NET C# - Gridview with dropdownlist from the database and outside add,edit delete buttons outside the gridview ? ASP.NET C# 如何获取 Asp.Net Core DropdownList 以在 C# 枚举中显示 [Display()] 值? - How do I get an Asp.Net Core DropdownList to show the [Display()] values in a C# enum?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM