I have dropdown & Gridview on FrmSatelliteMain,In dropdown DataValueField uid is there,Now i want that as the user selects
the value in dropdown ,on basis of uid i will fetch the records fromm DB & bind to Gridview using AJAX.
Plz frnds dont tell me dat,dat do it using AJAX framework!!!!!
Code:public partial class FrmSatelliteMain : System.Web.UI.Page { SqlConnection conn = new SqlConnection("Data Source=(local);Initial catalog=SatelliteTVonPV;User ID=sonia;Password=sonia"); string Query; SqlCommand cmd; SqlDataReader dr; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownLanguages.Attributes.Add("onChange", "javascript:return AddChannels()"); } } }
SOURCE CODE-
In DropDownLanguages in DataValueField,UID is there.I want to retrive all the records from DB that has UID 1 in country column.
Code:<script type ="text/javascript" language ="javascript"> var xmlHttp; function AddChannels() { checkXHR("Retrieve.aspx?&uid="+document.getElementById("DropDownLanguages").value); } function checkXHR(url) { try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.open("GET",url,false); xmlHttp.onreadystatechange=statechanged; xmlHttp.send(null); } function statechanged() { if(xmlHttp.readyState==4) { document.getElementById("hd1").value = xmlHttp.responseText; } else { document.getElementById("hd1").value=""; } }
FRMRETRIVE.aspx
Code:public partial class Retrieve : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("select * from [pctv] where Country='" + Request["uid"].ToUpper() + "'", conn); DataSet ds = new DataSet(); da.Fill(ds); } }
In FrmRetrive form load,Records are coming,But i dont know that how to bind this data with Gridview of FrmSatelliteMain!! Can somebody tell me dat???????????I want to bind all the columns excluding UID,category & Country!!
DB Columns
UID
Country
Category
Language
Channel Name
Channel URL
TV RATING


Reply With Quote