Solved
Use a WEB service to populate a foreach loop?
Posted on 2006-11-14
Hi there
Wonder if you guys can help me with a problem? I'm using ASP.NET/C#/VS2005.
I have the following code in my page_load event. As you can see the connection string + the select statement is display. I've created a WEB service that gets all the information I need from a table. How do I use it with the foreach loop? I dont want to use strCmd, m_connString etc, I simply want to use my web service. Here is the code for the web service:
string m_connString;
string strCmd = "SELECT * FROM Attachments";
m_connString = "Data Source=.;Initial Catalog=Handbook;Integrated Security=True";
SqlDataAdapter da = new SqlDataAdapter(strCmd, m_connString);
DataSet ds = new DataSet();
da.Fill(ds, "Attachments");
foreach (DataRow row in ds.Tables["Attachments"].Rows)
{
string html = "<div title='" + row["Attachments_fileName"] + "' myAttrSrc='" + row["Attachments_URL"]
+ "'onmouseover=\"this.style.cursor='pointer'\" onclick=\"myOnClick(event,'" + row["Attachments_URL"]
+ "',false)\" ondblclick=\"myOnClick(event,'" + row["Attachments_URL"] + "',true)\"> " + row
["Attachments_fileName"] + "</div>";
Place.Text += html;
}
ds.CreateDataReader();
=========================================================
My web service code is as follows:
WS_Handbook.Handbook_WS deleteMe = new WS_Handbook.Handbook_WS();
deleteMe.displayAttachments();
Many thanks
Mousemat24