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

查看:53
本文介绍了在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天全站免登陆