Click here to Skip to main content
15,895,192 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can i write the this code in websevices
XML
int m = 20;
       SqlConnection objConnection = new SqlConnection(@"Data Source=STANZOO-FE82BEA\SQLEXPRESS;Initial Catalog=stanzoo;Integrated Security=True");
       SqlDataAdapter objdata = new SqlDataAdapter("select distinct categoryid,category from items where category like '" + hdntxtcategories.Value.ToString() + "%'", objConnection);
       SqlDataAdapter objdata1 = new SqlDataAdapter("select Top 10 subcategoryid,subcategory from items where subcategory like '" + hdntxtcategories.Value.ToString() + "%'", objConnection);
       DataSet objdataset = new DataSet();
       DataSet objdataset1 = new DataSet();
       objdata.Fill(objdataset, "Categories");
       objdata1.Fill(objdataset1, "SubCategories");
       string constructTable = "<table border='1' cellpadding='5' cellspacing='5' height='150px'>";
       constructTable += "<tr><td style='vertical-align:top'>";
       constructTable += "<div id='s' style='background-color:red;width:150px;align:center'>Categories</div>";
       for (int i = 0; i < objdataset.Tables[0].Rows.Count; i++)
       {
           // int s=0;
           //s++;
           HiddenField1.Value = objdataset.Tables[0].Rows.Count.ToString();
           constructTable += "<a style='cursor:pointer';  onclick='javascript:ShowCategory(" + objdataset.Tables[0].Rows[i]["categoryid"].ToString() + ")'><div id='" + i + "'>" + objdataset.Tables[0].Rows[i]["category"] + "</div></a>";
       }
       constructTable += "</td><td style='vertical-align:top'>";
       constructTable += "<div style='background-color:red;width:150px;align:center'>Sub Categories</div>";
       for (int i = 0; i < objdataset1.Tables[0].Rows.Count; i++)
       {
           HiddenField2.Value = objdataset1.Tables[0].Rows.Count.ToString();
           constructTable += "<div id=" + m + " style='cursor:hand' onclick='javascript:ShowSubcategory(" + objdataset1.Tables[0].Rows[i]["subcategoryid"].ToString() + ")'>" + objdataset1.Tables[0].Rows[i]["subcategory"] + "</div>";
           m++;
       }
       constructTable += "</td></tr></table>";
       divTable.InnerHtml = constructTable;
Posted
Comments
shakil0304003 25-Nov-10 8:48am    
!!!!

1 solution

This code in webservice?

You need to be clear on what webservice is and how it works. Webservice will expose a webmethod that will communicate with database and bring data.

Now based on what I can figure out from your question, it looks like you need:
1. from client javascript, send request to server for data
2. Server will talk to webservice to bring data
3. once data recieved, it will be sent to client and then use that data for display.

Read on these and then try.
 
Share this answer
 
Comments
Dalek Dave 25-Nov-10 9:27am    
Here is Wisdom.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900