使用sql数据源更新网格视图中的数据时,是否提交下拉列表值的选定值? [英] submit selected value of drop down list value when update data in grid view with sql data source?

查看:92
本文介绍了使用sql数据源更新网格视图中的数据时,是否提交下拉列表值的选定值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dears,

我有网格视图从sql数据源获取数据,

和一列是外键所以我做了另一个sql数据源来获取值,



除了在编辑模式下更新下拉列表中的值外,每件事都可以正常工作(获取数据和选择),



这里是我的代码摘要:

主要数据来源(机场建筑物):

Dears,
I have grid view which get data from sql data source,
and one column are foreign key so i made another sql Data source to get the value,

Every thing work fine (getting data and select) except updating the value in drop down list in edit mode,

here is summary of my code:
Main Data Source (Airport Buildings):

<asp:SqlDataSource ID="SqlDataSource1">
 <UpdateParameters>
 <asp:Parameter Name="AirportID" Type="Int32"   />
 <asp:Parameter Name="BuildingID" Type="Int32" />
 <asp:Parameter Name="BuildingName" Type="String" />
 <asp:Parameter Name="Description" Type="String" />
 </UpdateParameters>
</asp:SqlDataSource>

Source of Lookup tabel:
 <asp:SqlDataSource ID="sdsAirports"/>





Grid View列,DataSourceID =SqlDataSource1:



column of Grid View with DataSourceID="SqlDataSource1" :

  <asp:TemplateField HeaderText="AirportID" SortExpression="AirportID" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1"  runat="server"  DataSourceID="sdsAirports" DataTextField="AirportName" DataValueField="AirportID"  SelectedValue='<%# Eval("AirportID").ToString() %>' >
</asp:DropDownList>
                                
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="DropDownList11" runat="server" DataSourceID="sdsAirports" DataTextField="AirportName" DataValueField="AirportID" SelectedValue='<%# Eval("AirportID").ToString() %>' Enabled="false">
 </asp:DropDownList>
 <%--<asp:Label ID="Label1" runat="server" Text='<%# Bind("AirportName") %>'></asp:Label>--%>
</ItemTemplate>
                           
</asp:TemplateField>

 <asp:TemplateField HeaderText="BuildingName" SortExpression="BuildingName">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("BuildingName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("BuildingName") %>'></asp:Label>
</ItemTemplate>

</asp:TemplateField>

推荐答案

尝试设置SelectedValue以及下拉列表的SelectedText
Try setting the SelectedValue as well SelectedText of the drop down


在我的网格视图中的问题我有相同字段的密钥,似乎相同的数据发送到存储过程所以没有更改。



alhamdullah
The issue in my grid view i have key for the same field and it seems that the same data send to stored procedure so no changes.

alhamdullah


这篇关于使用sql数据源更新网格视图中的数据时,是否提交下拉列表值的选定值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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