很抱歉重复这个问题,但我搜索了几乎所有关于stackoverflow的问题,但没有找到任何解决方案。我实现了一个gridview,其中我使用WHERE子句,但得到了gridview。
这是代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDS1">
<Columns>
<asp:BoundField DataField="alert_title" HeaderText="alert_title"
SortExpression="alert_title" />
<asp:BoundField DataField="alert_desc" HeaderText="alert_desc"
SortExpression="alert_desc" />
<asp:BoundField DataField="alert_deadline" HeaderText="alert_deadline"
SortExpression="alert_deadline" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDS1" runat="server"
ConnectionString="<%$ ConnectionStrings:SQL %>"
SelectCommand="SELECT [alert_title], [alert_desc], [alert_deadline] FROM [Table_Alerts] WHERE [alert_owner] = @alert_owner ">
<SelectParameters>
<asp:Parameter Name="alert_owner" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
aspx.cs文件
protected void Page_Load(object sender, EventArgs e)
{
string Value = "muneeb";
//Parameter par = new Parameter("@alert_owner", DbType.String,Value);
//SqlDS1.SelectParameters.Add(par);
SqlDS1.SelectParameters["@alert_owner"].DefaultValue = "muneeb";
}
实施后,在
进行了预测 SqlDS1.SelectParameters["@alert_owner"].DefaultValue = "muneeb";
有些人可以告诉我哪里出错了吗?或者我该如何解决它。在此先感谢