<webmethod()> _ Public Function ChkBoxService() As String Dim sql As String = "select distinct FoodType from HallFoodingTrans where HallCode= 'HC1309000004'" Dim con As New SqlConnection(ConfigurationManager.AppSettings("myConnection")) Dim cmd As New SqlCommand(sql, con) Dim da As New SqlDataAdapter(cmd) Dim ds As New DataSet() da.Fill(ds) 'var(id = "id") Dim lbl As String = "lbl" Dim dividouter As String = "dividouter" Dim dividinner As String = "dividinner" Dim chkboxFoodName As String = "chkboxFoodName" Dim labelFoodRate As String = "labelFoodRate" Dim txtInputFoodRate As String = "txtInputFoodRate" Dim tablestring As String = "" If ds.Tables(0).Rows.Count <> 0 Then Dim i As Integer = 0 For Each dr As DataRow In ds.Tables(0).Rows tablestring = tablestring + ("<div id='dividouter" & i & "' >") tablestring = tablestring + "<label id='lbl" & i & "' >" & dr("FoodType").ToString() & "</label> " Dim sql1 As String = "select distinct FoodName,Rate from HallFoodingTrans where FoodType= '" & dr("FoodType").ToString() & "' and HallCode= 'HC1309000004 '" Dim con1 As New SqlConnection(ConfigurationManager.AppSettings("myConnection")) Dim cmd1 As New SqlCommand(sql1, con1) Dim da1 As New SqlDataAdapter(cmd1) Dim ds1 As New DataTable() da1.Fill(ds1) Dim j As Integer = 0 If ds1.Rows.Count > 0 Then tablestring = tablestring + ("<div id='dividinner" & i & "" & j & "' >") tablestring = tablestring + "<table width='100%'><tr><td>First Column Head</td><td>Second column Head</td><td>Third column Heading</td></tr>" Do While j < ds1.Rows.Count With ds1.Rows(j) tablestring = tablestring + "<tr><td><input type='checkbox' id='chkboxFoodName" & i & "" & j & "' >" & .Item("FoodName").ToString & "</td><td><label id='labelFoodRate" & i & "" & j & "' >" & .Item("Rate").ToString & "</td><td><input type='text' id='txtInputFoodRate" & i & "" & j & "'></td></tr>" j = j + 1 End With Loop tablestring = tablestring + "</table>" tablestring = tablestring + "</div>" End If tablestring = tablestring + "</div>" i += 1 Next End If Return tablestring End Function
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="js/jquery-1.9.1.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajax({ type: "POST", url: "MyWebService.asmx/ChkBoxService", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { var myData = data.d; alert(myData); $('#chkwebservice').html(myData); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div id="chkwebservice" style ="background-color:Green; height:500px;"> </div> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)