我试图搜索gridview但是失败了,请告诉我我哪里做错了,或者我需要包含参考? 我的javascript
<script type="text/javascript">
function Search_Gridview(strKey, strGV) {
var strData = strKey.value.toLowerCase().split(" ");
var tblData = document.getElementById(strGV);
var rowData;
for (var i = 1; i < tblData.rows.length; i++) {
rowData = tblData.rows[i].innerHTML;
var styleDisplay = 'none';
for (var j = 0; j < strData.length; j++) {
if (rowData.toLowerCase().indexOf(strData[j]) >= 0)
styleDisplay = '';
else {
styleDisplay = 'none';
break;
}
}
tblData.rows[i].style.display = styleDisplay;
}
}
我的gridview
<div style="border: 1px solid Black; width: 800px; padding: 20px; height: 350px;
font-size: 20px;">
Search :
<asp:TextBox ID="txtSearch" runat="server" Font-Size="20px" onkeyup="Search_Gridview(this, 'gvTest')"></asp:TextBox><br />
<br />
<asp:GridView ID="gvTest" runat="server" CellPadding="10" Width="500px">
</asp:GridView>
我的c#数据填充gridview
private void FillRoleGrid()
{
string constr = ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT EmployeeNo,Name,POsition FROM userInfo"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
gvTest.DataSource = dt;
gvTest.DataBind();
}
}
}
}
}
我完全不知道我哪里做错了,请指导我,谢谢。
答案 0 :(得分:0)
var strGV =&#39;&lt;%= gvTest.ClientID%&gt;&#39;在javascript。