Hi,All
see my code a help to bind select element
[WebMethod(EnableSession = true)]
public void GetTpoName()
{
SqlConnection con = null;
string q = Context.Request.QueryString["q"];
string rValue = string.Empty;
try
{
SqlCommand cmd;
con = new SqlConnection(Constants.SqlConnectionString);
cmd = new SqlCommand("select UserId,Name from UserTable where OrganisationId=@id", con);
cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.SmallInt)).Value = q;
con.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dr.Read())
{
rValue += string.Format("{0}|{1}\n", dr["Name"], dr["Organisationid"]);
}
con.Close();
}
catch
{
}
finally
{
if (con != null)
{
con.Dispose();
}
}
Context.Response.Write(rValue);
}
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#selecttpo").load("admin211181.asmx/GetTpoName",function(event,item){
$("#selecttpo").val(item[1]);
});
});
</script>
<title>Untitled Page</title>