Here is my WebMethod which will return products against user enter amount and person. Now same i want to do on my website please help me
public DataSet Restaurant(decimal amount, decimal persons)
{
decimal price = amount / persons ;
DataSet result = null;
const string SQL_COMMAND_TEXT = "SELECT Product_Name,Product_Price FROM Table1234 WHERE Product_Price <= @price";
using (SqlConnection connection = Class1.GetConnection())
{
connection.Open();
using (SqlCommand command = new SqlCommand(SQL_COMMAND_TEXT, connection))
{
command.Parameters.Add("@Rst_Name", SqlDbType.NVarChar);
command.Parameters.Add("@Persons", SqlDbType.NVarChar);
command.Parameters.Add("@price", SqlDbType.SmallMoney);
command.Parameters["@Rst_Name"].Value = amount;
command.Parameters["@persons"].Value = persons;
command.Parameters["@price"].Value = price;
using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
{
result = new DataSet();
dataAdapter.Fill(result);
}
}
}
return result;
}
Ali AshiqPosted Feb 9, 2014, 1:56 AM
i know its a textbox id but still i am getting error.
Ali AshiqPosted Feb 9, 2014, 1:52 AM
Mam i got error on this portion it goes over my head:'( will you please define this thing
Biswa Pujarini MohapatraPosted Feb 9, 2014, 12:42 AM
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
step 2 -<script type="text/javascript" src="script/jquery-1.2.6.min.js">script>
<script type="text/javascript">
function getRestuarants() {
$.ajax({
type: "POST",
url: "WebService.asmx/Restaurant",
data: "{amount: " + $('#<%= txtprice.ClientID %>').val() + " , persons: " + $('#<%= txtpersons.ClientID %>').val() + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
//do things bind your drop down
});
}
script>
Ali AshiqPosted Feb 8, 2014, 4:53 PM
Ali AshiqPosted Feb 8, 2014, 7:49 AM
Ali AshiqPosted Feb 8, 2014, 7:29 AM
Biswa Pujarini MohapatraPosted Feb 8, 2014, 5:55 AM