1、页面代码

Gridview使用(三)Gridview中绑定DropDownList                        <asp:TemplateField HeaderText="等级">
Gridview使用(三)Gridview中绑定DropDownList                            
<ItemTemplate>
Gridview使用(三)Gridview中绑定DropDownList                                
<asp:Label ID="Label6" runat="server" Text='<%# FormatUserlevel(Eval("User_UserLevel"))%>'></asp:Label>
Gridview使用(三)Gridview中绑定DropDownList                            
</ItemTemplate>
Gridview使用(三)Gridview中绑定DropDownList                            
<EditItemTemplate>
Gridview使用(三)Gridview中绑定DropDownList  //这个label的作用是为了在后台控制
当你点击编辑按钮的时 DropDownList 的选中值,                         <asp:Label ID="Label7" runat="server" Text='<%# Eval("User_UserLevel")%>' Visible="false"></asp:Label>
Gridview使用(三)Gridview中绑定DropDownList                                
<asp:DropDownList ID="ddl_userLevel" runat="server" >
Gridview使用(三)Gridview中绑定DropDownList                                
</asp:DropDownList>
Gridview使用(三)Gridview中绑定DropDownList                            
</EditItemTemplate>
Gridview使用(三)Gridview中绑定DropDownList                        
</asp:TemplateField>

将此列设为模版,在现实数据的时候是以label形式,当点击控件自带的编辑按钮的时候就是以DropDownList形势显示

2、后台代码

Gridview使用(三)Gridview中绑定DropDownList    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    }

 

 

 

 

 

相关文章: