怎么使用控件参数?用DropDownList控制GridView. 10
aspx代码:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="...
aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
Height="172px" Width="234px">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cConnectionString %>"
SelectCommand="SELECT * FROM [Table1]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ID" PropertyName="SelectedVaule" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="ID" DataValueField="ID">
</asp:DropDownList></div>
</form>
</body>
</html>
在浏览器中的错误提示:
DataBinding:“System.Web.UI.WebControls.DropDownList”不包含名为“SelectedVaule”的属性。 展开
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
Height="172px" Width="234px">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cConnectionString %>"
SelectCommand="SELECT * FROM [Table1]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ID" PropertyName="SelectedVaule" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="ID" DataValueField="ID">
</asp:DropDownList></div>
</form>
</body>
</html>
在浏览器中的错误提示:
DataBinding:“System.Web.UI.WebControls.DropDownList”不包含名为“SelectedVaule”的属性。 展开
展开全部
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cConnectionString %>"
SelectCommand="SELECT * FROM [Table1]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ID" PropertyName="SelectedVaule" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
--------------------------------------------------
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="ID" DataValueField="ID">
</asp:DropDownList>
你这两个控件有冲突,循环依赖! dropdownlist1依赖了SqlDataSource1,而SqlDataSource1又依赖DropDownList1
而且最要命的是DropDownList1又没有给初值
SelectCommand="SELECT * FROM [Table1]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ID" PropertyName="SelectedVaule" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
--------------------------------------------------
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="ID" DataValueField="ID">
</asp:DropDownList>
你这两个控件有冲突,循环依赖! dropdownlist1依赖了SqlDataSource1,而SqlDataSource1又依赖DropDownList1
而且最要命的是DropDownList1又没有给初值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询