Click here to Skip to main content
15,914,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, all
I have written code for autocomplete extender for dynamic textboxes. Now i want to pass a session variables for this autocomplete extender webservice. I am not calling the webservice through aspx.cs code, it is coming dynamically. While user logged in, then my Session is created. Now i Want to send this session to the particular autocomplete extender Webservice Method. Any one plz help me.

This is My code

C#
<pre>[WebMethod ]
    public string[] GetCompletionList(string prefixText, int count)
    {
         DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        cn.ConnectionString = Connection;
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.Text;
       
        prefixText = "%" + prefixText + "%";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "spName";
        cmd.Parameters.AddWithValue("@iAccountId", Convert.ToInt32(
Session["iAccountId"].ToString()));
//Here iam getting Session["iAccountId"]=null
       cmd.Parameters.AddWithValue("@PrefixText", prefixText);
       try
        {
            cn.Open();
            cmd.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds);
        }
        catch
        {
        }
        finally
        {
            cn.Close();
        }
        dt = ds.Tables[0];
        //Then return List of string(txtItems) as result
        List<string> txtItems = new List<string>();
        String dbValues;
        foreach (DataRow row in dt.Rows)
        {
            //String From DataBase(dbValues)
            dbValues = row["vcRemarks"].ToString();
            //dbValues = dbValues.ToLowerInvariant ();
            txtItems.Add(dbValues);
        }
        return txtItems.ToArray();
    }



Thanks in Advance

Murthy
Posted

1 solution

Hi write like this

C#
[System.Web.Services.WebMethod(EnableSession = true)]

public string[] autoSuggestIndiv(string prefixText, int count, string contextKey) 

{

//your coding

}
 
Share this answer
 
v2

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