GridView中编辑状态下实现DropDownList默认值(原创)
2009-12-14 09:31
435 查看
之前看到很多网友包括孟子e章兄的默认值方法,觉得比较麻烦,自己写了个简单方法,欢迎大家指证!
前台:
<asp:TemplateField HeaderText="资质">
<ItemTemplate>
<asp:Label ID="lblAptitude" runat="server" Text='<%#Eval("Aptitude") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lbl2" runat="server" Text='<%#Eval("Aptitude") %>' style="display:none;"></asp:Label>
<asp:DropDownList ID="ddlAptitude" runat="server">
<asp:ListItem Value="合格" Text="合格"></asp:ListItem>
<asp:ListItem Value="储备" Text="储备"></asp:ListItem>
<asp:ListItem Value="潜在" Text="潜在"></asp:ListItem>
<asp:ListItem Value="不合格" Text="不合格"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
后台:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == gvList.EditIndex)
{
//编辑时下拉菜单默认值
ddlAptitude.Text = ((Label)e.Row.FindControl("lbl2")).Text;
}
}
欢迎大家发表意见,xiexie
前台:
<asp:TemplateField HeaderText="资质">
<ItemTemplate>
<asp:Label ID="lblAptitude" runat="server" Text='<%#Eval("Aptitude") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lbl2" runat="server" Text='<%#Eval("Aptitude") %>' style="display:none;"></asp:Label>
<asp:DropDownList ID="ddlAptitude" runat="server">
<asp:ListItem Value="合格" Text="合格"></asp:ListItem>
<asp:ListItem Value="储备" Text="储备"></asp:ListItem>
<asp:ListItem Value="潜在" Text="潜在"></asp:ListItem>
<asp:ListItem Value="不合格" Text="不合格"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
后台:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == gvList.EditIndex)
{
//编辑时下拉菜单默认值
ddlAptitude.Text = ((Label)e.Row.FindControl("lbl2")).Text;
}
}
欢迎大家发表意见,xiexie
相关文章推荐
- GridView 中如何实现编辑 删除(在编辑状态中 嵌套DropDownList)
- 在gridview编辑时添加dropdownlist控件设置默认值
- GridView 模版列编辑状态Dropdownlist 事件
- 在Gridview编辑时添加DropDownList控件并设置默认值
- GridView 把某一列设置为在编辑状态时是 DropDownList 下拉选项
- GridView控件编辑状态下的DropDownList控件选中原值
- Asp.Net GridView 在编辑状态中使用动态Dropdownlist方法
- GridView编辑状态绑定DropDownlist时,出现偶数行不能绑定情况
- GridView编辑状态下DropDownList的联动
- ASP.NET 2.0 GridVieW中控制一个DropDownList在编辑状态时出现对应值
- GridView编辑状态下DropDownList的联动
- gridview 编辑状态下的列表框(DropDownList)使用注意
- 在gridview编辑中添加dropdownlist控件并使其为数据库的默认值
- gridview 编辑状态下的列表框(DropDownList)使用注意
- GridView中如何实现导出含DropdownList、TextBox,实现分页及导出Excel数据
- .net 当GridView编辑状态获取新值时,往往获取的是修改前的值。
- GridView行编辑中找DropDownList控件
- GridView 实现自定义分页、排序、查询、添加、编辑、多选删除
- ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
- 利用AJAX实现DropDownList与GridView做实时更新