Need some advice. I’ve setup the following HttpWebRequest, which goes over to another server and retrieves data from there in htnl format – but I can change this to another structre.
What I would like to do is databind the data from there and present it nicely using repeaters and a list control in my website.
I’ve got most of code here below. The question I need to ask is, can I databind my responseData object the way I’ve got it setup. Secondly, I can configure the page at the other end to produce output in most formats. If I have customername,contact,telephone,email, how shall I present structure wise so I can use it as a databind object?
Hope the question makes sense. Thanks as always
string url = "https://myaddress/customerlist.php";
// creates the post data for the POST request
string postData = "ID=" + username + "&Token=" + token;
// create the POST request
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = postData.Length;
// POST the data
using (StreamWriter requestWriter2 = new StreamWriter(webRequest.GetRequestStream()))
{
requestWriter2.Write(postData);
}
// This actually does the request and gets the response back
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
string responseData = string.Empty;
using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream()))
{
// dumps the HTML from the response into a string variable
responseData = responseReader.ReadToEnd();
}
ReportRepeater.DataSource = responseData;
ReportRepeater.DataBind();
you should transform
responseDatain a list of custom object in order to bind it to the repeaterWhere ParseResponse is a custom method like this:
A good explanation to how use repeater:
http://msdn.microsoft.com/en-us/magazine/cc163780.aspx