ASP.NET - how to select the gridview records with simple xmlhttprequest
Asked By prakash rg
04-Feb-12 12:10 AM
1. binding gridview from database.
2. design one textbox,
When ever type a sentence or a single word in
the text box, it will automatically display those records in grid view.
using xmlhttrequest with javascript in asp.net C#.
please help me.......
D Company replied to prakash rg

Hello Friend.
you have asked two questions
1. binding gridview from database.
2. design one textbox,
When ever type a sentence or a single word in
the text box, it will automatically display those records in grid view.
i think second would serve the same purpose, because when an user type something on textbox, it will filter the data and bind it to gridview.
and this can be done using AJAX ENABLED GRIDVIEW.
for this you havto handle HTTP request and responses, somthing like as below sample.
/* This function is used to handler the http response */
function HandleResponse(Id) {
var childGridDiv = document.getElementById("div" + Id);
var childRow = document.getElementById("tr" + Id);
var img = document.getElementById('img' + Id);
// If Response completed
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
// Here is the response
var str = xmlHttp.responseText;
childGridDiv.innerHTML = str;
xmlHttp.abort();
// Mark the flag, Child Grid is fetched from server
document.getElementById('hid' + Id).value = '1';
}
else {
childRow.style.display = "none";
img.src = "images/plus.png";
}
}
else {
// Show the Progress status
childGridDiv.innerHTML = "<div style='padding:4px;'><img src='Images/ajax-loader.gif' alt='' /><span style='color:blue;font-size:17px;font-weight:bold;'>Loading... Please wait</span></div>";
childRow.style.display = "block";
img.src = "images/minus.png";
}
}
/* function to create Ajax object */
function createAjaxObject() {
var ro;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
if (xmlHttp != null) {
xmlHttp.abort();
}
ro = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
if (xmlHttp != null) {
xmlHttp.abort();
}
ro = new XMLHttpRequest();
}
return ro;
}
/* Get the XML Http Object */
function GetXmlHttpObject(handler) {
var objXmlHttp = null;
if (is_ie) {
var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
try {
objXmlHttp = new ActiveXObject(strObjName);
objXmlHttp.onreadystatechange = handler;
}
catch (e) {
alert('Object could not be created');
return;
}
}
return objXmlHttp;
}
function xmlHttp_Get(xmlhttp, url) {
xmlhttp.open('GET', url, true);
xmlhttp.send(null);
Note:-just learn some good tutorial about this concept it will help you.
Hope it helps
Regards
D
prakash rg replied to D Company
ok. how to write c# coding in cs file.
D Company replied to prakash rg
hello friend,
do u mean Inline coding,cs( i assume client side).
<%@ Import Namespace="System" %>
<%@ Page Language="c#"%>
<script runat="server">
public string ServerSideFunction(string input)
{
return "Hello " + input;
}
</script>
than write like this
Regards
D

Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B cache object? (A) What are dependencies in cache and types of dependencies? (A)Can you show a simple code showing file dependency in cache? (A) What is Cache Callback in Cache A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET
net ADO is designed primarily for connected access ADO.net the disconnected access to the database is used In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to or the APIs provided by the underlying data source. In ADO you cant update the database from the recordset. ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database. On order to get assembly info which namespace we should import? System.Reflection Namespace How tab”) This will fill the dataset with the records starting at 5 to 15 .NET Database interview questions How do you call and execute a Stored Procedure in.NET? Give an in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to
Tracing in ASP.NET? hi all, what is tracing? how to achieve tracing in asp.net? different ways of doing tracing? thanks and regards Aman Khan hi. . Tracing in ASP.NET 2.0 Tracing is a way to monitor the execution of your ASP.NET application. You can record exception details and program flow in a way that doesn't
if (!Page.IsPostBack) { GridView1.DataSource = BindData(); GridView1.DataBind(); } } private string ConnectionString { get { return @"Server = localhost;Database = Northwind; Trusted_Connection = true"; } } private DataSet BindData() { / / make the query string query = "SELECT * FROM Categories"; SqlConnection override void VerifyRenderingInServerForm(Control control) { / / Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time. } } Follow this code for exporting data from GridView to Excel else { throw new Exception("GridView control cannot be null or empty!"); } } } and now let me show you how to use it. Here's my .aspx page which contains a simple GridView control which has data assigned from the Northwind database and it pulls a list of employees and a simple button with event handler attached Stamp". These are very useful for time sensitive reports. 3) PageSize: If you are using Pagination in your GridView, you can choose to export the "Current" page, the "Entire Grid" all pages or set a specific number of records to export. Use "All" for all this property. You do not have to set any value if you just have one grid view. 6) File Name: You can set the filename that you want to export. Hope