如何通过单击搜索按钮在gridview中显示数据 [英] how to show the data in gridview by clicking the search button
本文介绍了如何通过单击搜索按钮在gridview中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的屏幕包含带有ID txtid的文本框和带有ID btnsearch的搜索按钮以及带有ID GridviewID的网格视图
i必须通过在文本框中输入人员ID在网格视图中显示带有人物图像的数据然后单击搜索按钮。
i have screen with textbox with ID txtid and search button with ID btnsearch and a gridview with id GridviewID
i have to show the data with person image in grid view by enter person ID in the text box and click the search button .
推荐答案
创建一个参数化查询或存储过程,该查询或存储过程根据从前端传递的PersonID返回Person信息。从代码隐藏(甚至是搜索按钮)执行此查询,传入从txtID文本框输入的值。返回结果,然后将结果分配给GridView。下面是存储过程的一个简单示例。
Create a parameterized query or stored procedure that returns the Person information based on the PersonID passed from your front-end. Execute this query from your code-behind (the Search button even) passing in the value entered from the txtID textbox. Return the result, and then assign that result to your GridView. Below is a simple example of the stored procedure.
CREATE PROCEDURE GetPersonByID
(
@PersonID INT
)
SELECT * FROM Person
WHERE
PersonID = @PersonID
这篇关于如何通过单击搜索按钮在gridview中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文