SqlDatasource选择参数
这是我的 sql 数据源详细信息
<asp:SqlDataSource ID="dsMoodleQuiz" runat="server"
ConnectionString="<%$ ConnectionStrings:OnlineMeetingConnectionString %>"
ProviderName="<%$ ConnectionStrings:OnlineMeetingConnectionString.ProviderName %>"
SelectCommand="SELECT Name, UserID, Grade, FirstName, LastName, Email, TimeModified, IDNumber FROM tbMoodleQuiz WHERE (FirstName = @FirstName) AND (LastName = @LastName)"
onselecting="dsMoodleQuiz_Selecting">
<SelectParameters>
<asp:Parameter Name="FirstName" />
<asp:Parameter Name="LastName" />
</SelectParameters>
</asp:SqlDataSource>
名为 gvDetails 的 gridview 附加到 dsMoodleQuiz 。在按钮单击
上,我希望
填充gridview。
这是按钮单击的代码
protected void btnSearch_Click(object sender, EventArgs e)
{
dsMoodleQuiz.SelectParameters.Add("@FirstName", System.Data.DbType.String, "Jhon");
dsMoodleQuiz.SelectParameters.Add("@LastName", System.Data.DbType.String, "Wald");
GridView1.DataBind();
}
为什么这不起作用......?我是否缺少任何代码...?感谢您的帮助
Here is my sql datasource details
<asp:SqlDataSource ID="dsMoodleQuiz" runat="server"
ConnectionString="<%$ ConnectionStrings:OnlineMeetingConnectionString %>"
ProviderName="<%$ ConnectionStrings:OnlineMeetingConnectionString.ProviderName %>"
SelectCommand="SELECT Name, UserID, Grade, FirstName, LastName, Email, TimeModified, IDNumber FROM tbMoodleQuiz WHERE (FirstName = @FirstName) AND (LastName = @LastName)"
onselecting="dsMoodleQuiz_Selecting">
<SelectParameters>
<asp:Parameter Name="FirstName" />
<asp:Parameter Name="LastName" />
</SelectParameters>
</asp:SqlDataSource>
A gridview by name gvDetails is attached to dsMoodleQuiz . On button click
I would like
gridview to get populated.
Here is the code on button click
protected void btnSearch_Click(object sender, EventArgs e)
{
dsMoodleQuiz.SelectParameters.Add("@FirstName", System.Data.DbType.String, "Jhon");
dsMoodleQuiz.SelectParameters.Add("@LastName", System.Data.DbType.String, "Wald");
GridView1.DataBind();
}
Why is this not working ...?? Am I missing any code ...?? Appreciate the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是关于如何使用 sqldatasource 搜索网格视图并根据该搜索条件填充结果的示例示例...
网格视图绑定...
并且 sql 数据源就像这样...
添加用于搜索的文本框..
这是用于绑定和在文本框中输入文本的代码
,这是用于高亮显示的 css 样式..
这是上面网格视图的图像
希望对您有帮助...
This is sample example on how to search grid view and populating results on that search criteria using sqldatasource.....
grid view binding .....
and sql datasource is like this ...
adding text box for searching ..
and this is code for binding and entering text into text box
and this is the css style for hilighting..
and this is teh image for the above grid view
i hope it will helps you...
在databandg中使用以下代码
注意:我没有Visual Studio,所以代码不可复制,可粘贴。
Using the following code in databaindg
Note: I dont have visual studio with me, so the code is not copy, pastable.