带有jQuery的webservices

带有jQuery的webservices

本文介绍了带有jQuery的webservices的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Websevices中编写此代码

 int m = 20;
       SqlConnection objConnection =新的SqlConnection(@数据源= STANZOO-FE82BEA \ SQLEXPRESS;初始目录= stanzoo;集成安全性= True");
       SqlDataAdapter objdata = new SqlDataAdapter(从类别类似'" + hdntxtcategories.Value.ToString()+%'",objConnection的项目中选择不同的categoryid,类别);
       SqlDataAdapter objdata1 =新的SqlDataAdapter(选择前10个子类别,从子类别(例如'" + hdntxtcategories.Value.ToString()+%'",objConnection)的项目中选择子类别);
       DataSet objdataset =新的DataSet();
       DataSet objdataset1 =新的DataSet();
       objdata.Fill(objdataset,"Categories");
       objdata1.Fill(objdataset1,"SubCategories");
       字符串ConstructTable ="<     边界  ='  1'   单元格填充  ='  5'   单元格间距  ='  5'   高度  ='  150px' > ;
       ConstructTable + ="<   tr  >  <   td    样式  ='  vertical-align:top' > ;
       ConstructTable + ="<   div     id   ='  s'   样式  ='  background-color:red; width:150px; align:center' >  Categories ><  /div  > ;
       for(int i = 0; i <     objdataset. Tables [0] .Rows.Count;     i ++) 
 
                     span>  { 
 
                     span>         //    int     s   =   0;
 
                     span>         //s ++;  
 
                     span>          HiddenField1.Value     =   objdataset.Tables [0] .Rows.Count.ToString();
 
                     span>          constructTable     +   =" < a style ='cursor:pointer'; onclick ='javascript:ShowCategory("     +     objdataset.Tables [0] .Rows [i] [" categoryid].ToString()    +    ")' >  <   div     id   ='  "+ i +"' > "+ objdataset.Tables [0] .Rows [i] [类别"] +"<  /div  >  <  /a   > ";
       }
       ConstructTable + ="<  /td  >  <   td    样式  ='  vertical-align:top' > ;
       ConstructTable + ="<   div    样式  ='  background-color:red; width:150px; align:center' > 子类别<  /div  > ";
       for(int i = 0; i <     objdataset1. Tables [0] .Rows.Count;     i ++) 
 
                     span>  { 
 
                     span>          HiddenField2.Value     =   objdataset1.Tables [0] .Rows.Count.ToString();
 
                     span>          constructTable     +   =" < div id ="   

span> + m + " 样式 =' cursor:hand' onclick =' javascript:ShowSubcategory("+ objdataset1.Tables [0]. Rows [i] ["subcategoryid"].ToString()+)' > " + objdataset1.Tables [0] .Rows [i] [子类别"] +"< /div > ; ; m ++; } ConstructTable + ="< /td > < /tr > < /table > ; divTable.InnerHtml = ConstructTable;

解决方案


How can i write the this code in websevices

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;
解决方案


这篇关于带有jQuery的webservices的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 20:36