在 EditItemTemplate 上设置 gridview DDL 的当前值 [英] Set the current value of gridview DDL on EditItemTemplate

查看:15
本文介绍了在 EditItemTemplate 上设置 gridview DDL 的当前值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 gridview 下拉列表中的选定值设置为当前记录中的值,就像我目前对文本框所做的那样.

How do I set the selected value in a gridview dropdownlist to what is in the current record like I currently do for a text box.

我希望用户可以查看当前值并决定是否需要更改它们——这就是我用于文本框的内容:

I am hoping the user can look at the current values and decide if they need to be changed -- this is what I use for a textbox:

<asp:TemplateField HeaderText="Other Notes" SortExpression="Other Notes" HeaderStyle-Wrap="false">
    <edititemtemplate>
        <asp:TextBox ID="txtOtherNotes" runat="server" Text='<%# Eval("[Other Notes]") %>' DataTextField="Other Notes" DataValueField="Other Notes"></asp:TextBox>
    </edititemtemplate>
    <itemtemplate>
        <asp:Label runat="server" Text='<%# Bind("[Other Notes]") %>' ID="lblOtherNotes"></asp:Label>
    </itemtemplate>
</asp:TemplateField>

推荐答案

我最终使用了:

 SelectedValue='<%# Bind("myID") %>' 

在ddl中显示当前记录.

to display the current record in the ddl.

这篇关于在 EditItemTemplate 上设置 gridview DDL 的当前值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆