hello,
this is my coding. the javascript function onkeyup is invoking when i type any text on textbox and assigning gridview client id inside the javascript. BUT WHY IT IS NOT DOING POSTBACK (Why it is not going to code behind language - aspx.cs)..I have been working on 4 days..really i am not able to figure out. if anybody knows, help me. Thank you.
here my coding:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"CodeBehind="Default.aspx.cs" Inherits="WebApplication6._Default" %>
<asp:Content ID="contentid" runat="server" ContentPlaceHolderID="ContentPlaceHolder2"><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>
</asp:Content>
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(string));dt.Rows.Add("What is IT", "information technology is changing everything");GridView1.DataSource = dt;GridView1.DataBind();}}}