hai to all
can any one help me out...
how to display the data from xml to gridview, where xml is in server(i.e in online)
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Krishna GaradPosted Jan 11, 2012, 12:19 PM
WebRequest rssReq = WebRequest.Create("Url With Xml File Path");
WebProxy px = new WebProxy("Proxy Url", true);
rssReq.Proxy = px;
rssReq.Timeout = 2000;
try
{
WebResponse rep = rssReq.GetResponse();
XmlTextReader xtr = new XmlTextReader(rep.GetResponseStream());
DataSet ds = new DataSet();
ds.ReadXml(xtr);
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
}
catch
{
return null;
}
If it asking credentials then you must have to provide network credentials
NetWorkCredentials crd=new NetworkCredentials("Uname","Pwd");
and then send credentials with webrequest.
Krishna GaradPosted Jan 12, 2012, 3:09 AM
If this help you please select Checkbox "This is correct answer"
shashi reddyPosted Jan 11, 2012, 9:29 AM
it worked for local xml..
but what i want is... xml file which is some where in server(url) ..i know the username and password..
now i wanna connect that xml file and i hve to show that xml data in a gridview
is it possible ..
Krishna GaradPosted Jan 11, 2012, 9:22 AM
string _file = Server.MapPath("~/XMLFile.xml");
DataSet ds = new DataSet();
ds.ReadXml(_file);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();