这是我的编码:
<script type="text/javascript" language="javascript">
function fun() {
debugger;
var x = document.getElementById('<%=GridView1.ClientID %>')
__doPostBack("<%=GridView1.ClientID%>", " ");
}
</script>
<asp:TextBox ID="txt" onkeyup="fun();" runat="server"></asp:TextBox>
<div>
<asp:GridView ID="GridView1" runat="server" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td><%# Eval("question") %></td>
</tr>
<tr>
<td><%# Eval("answer") %></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
aspx.cs(codebehind)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication6
{
public partial class _Default : System.Web.UI.Page
{
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
dt.Columns.Add("question", typeof(string));
dt.Columns.Add("answer", typeof(str`enter code here`ing));
dt.Rows.Add("What is IT", "information technology is changing everything");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}