搜索和显示数据网格中的数据 [英] search and display data from a datagrid

查看:57
本文介绍了搜索和显示数据网格中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请在以下方面帮助我:
我创建了一个datagrid 以使用ASP.NET和存储过程从SQL中的表中显示数据.
数据正在正确显示.

我想添加搜索功能.

单击搜索按钮后,所需的数据应显示在datagrid的单行中.
我想使用文本框插入搜索数据.

Hello all,

Please help me in the following:
I have created a datagrid to display data from a table in SQL using ASP.NET and stored procedures.
The data is getting displayed properly.

I want to add search functionality.

On clicking the search button, the required data should get displayed in a single row of the datagrid.
I want to use textboxes to insert search data.

推荐答案

^ ]可能会为您提供帮助
Also This[^] might help you.


请参阅以下某些内容-
http://articles.sitepoint.com/article/datagrid-searching-asp-net [ ^ ]

使用Index Server和.NET创建搜索页 [ http://www.c-sharpcorner.com/uploadfile/anjudidi/308062009080934am/3.aspx [ ^ ]
See some of the following -
http://articles.sitepoint.com/article/datagrid-searching-asp-net[^]

Creating Search Pages with Index Server and .NET[^][^]
http://www.c-sharpcorner.com/uploadfile/anjudidi/308062009080934am/3.aspx[^]


您能帮我什么吗?感谢所有回复..我的代码如下:
子fill_grid()
con.Open()
com =新的SqlCommand("proc_search",con)
com.CommandType = Data.CommandType.StoredProcedure
com.Parameters.Add(新SqlParameter("@ Mode",Data.SqlDbType.VarChar,20))
com.Parameters.AddWithValue("@ strFeedTitle",cmbtitle.Text)
com.Parameters.AddWithValue("@ strFeedNm",txtname.Text)
com.Parameters.AddWithValue("@ strFeedEmail",txtemail.Text)
com.Parameters("@ Mode").Value ="select1"
da =新的SqlDataAdapter
da.SelectCommand = com
da.SelectCommand.Connection = con
ds =新数据集
''ds.Tables.Add("tbl1")
da.Fill(ds,"tbl1")
con.Close()
试试
如果ds.Tables("tbl1").Rows.Count> 0然后
gd_feedback.DataSource = ds.Tables("tbl1").DefaultView
gd_feedback.DataBind()
gd_feedback.Visible = True
gd_feedback.EnableViewState = True
如果结束
异常捕获
Response.Write(ex.ToString)
结束尝试
结束Sub
Can u help me any further?? thanx to all for your replies..my code is as follows:
Sub fill_grid()
con.Open()
com = New SqlCommand("proc_search", con)
com.CommandType = Data.CommandType.StoredProcedure
com.Parameters.Add(New SqlParameter("@Mode", Data.SqlDbType.VarChar, 20))
com.Parameters.AddWithValue("@strFeedTitle", cmbtitle.Text)
com.Parameters.AddWithValue("@strFeedNm", txtname.Text)
com.Parameters.AddWithValue("@strFeedEmail", txtemail.Text)
com.Parameters("@Mode").Value = "select1"
da = New SqlDataAdapter
da.SelectCommand = com
da.SelectCommand.Connection = con
ds = New DataSet
''ds.Tables.Add("tbl1")
da.Fill(ds, "tbl1")
con.Close()
Try
If ds.Tables("tbl1").Rows.Count > 0 Then
gd_feedback.DataSource = ds.Tables("tbl1").DefaultView
gd_feedback.DataBind()
gd_feedback.Visible = True
gd_feedback.EnableViewState = True
End If
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub


这篇关于搜索和显示数据网格中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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