How we display value run time in two drop down list

  • 9 years ago
    Hi, I am missing something I would like to display Customer Name in first drop down list and Sales person with different query in second Drop down list using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;//Namespace Sytsem.Data.SqlClient dll added public partial class Obisals09 : System.Web.UI.Page { //declare the variable for Connection,Command and DataReader SqlConnection conn; SqlCommand cmd,cmd1; SqlDataReader dr,dr1; public string sqlquery1 = ""; public string sqlquery2 = ""; protected void Page_Load(object sender, EventArgs e) { //Sql for Drop down list sqlquery2 = "select distinct um_username+'('+um_userid+')' customer,um_userid from User_master,Customer_Outstanding where um_userid = cs_Customer_id and um_levelno=4 Union select distinct um_username+'('+um_userid+')', um_userid,' ' from User_master where um_userid not in (select cs_Customer_id from Customer_Outstanding)and um_levelno=4 and left(um_userid,3) <> 'WEB' and um_active='Y' order by customer"; sqlquery1 = "select distinct um_username+'('+um_userid+')' customer,um_userid,(case um_Dealer_ReportingTo when 'VK' then 'Vimal Kumar' when 'DC' then 'Dave Calderwood' when 'OI' then 'Obeetee Inc' end)abc,um_Dealer_ReportingTo,(case um_Dealer_ReportingTo when 'VK' then 'Vimal Kumar' when 'DC' then 'Dave Calderwood' when 'OI' then 'Obeetee Inc' end)+'('+um_Dealer_ReportingTo+')' Slarep from User_master,Customer_Outstanding where um_userid = cs_Customer_id and um_levelno=4 Union select distinct um_username+'('+um_userid+')', um_userid,(case um_Dealer_ReportingTo when 'VK' then 'Vimal Kumar' when 'DC' then 'Dave Calderwood' when 'OI' then 'Obeetee Inc' end)abc,um_Dealer_ReportingTo,(case um_Dealer_ReportingTo when 'VK' then 'Vimal Kumar' when 'DC' then 'Dave Calderwood' when 'OI' then 'Obeetee Inc' end)+'('+um_Dealer_ReportingTo+')' Slarep from User_master where um_userid not in (select cs_Customer_id from Customer_Outstanding)and um_levelno=4 and left(um_userid,3) <> 'WEB' and um_active='Y' order by customer"; //created a new Connection object using the connection string conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString1"]); //open the connection and execute the command conn.Open(); //create a new Command using the CommandText and Connection object cmd = new SqlCommand(sqlquery1, conn); //Execute DataReader SqlDataReader dr = cmd.ExecuteReader(); ddlcust1.DataSource = dr; cmd = new SqlCommand(sqlquery2, conn); //Execute DataReader SqlDataReader dr1 = cmd.ExecuteReader(); ddlsale.DataSource = dr1; //Declare IsPostback property of the Page class to executed Init function of the page if (!IsPostBack) { ddlcust1.DataValueField = "um_userid";// ddlcust1 first drop down name ddlcust1.DataTextField = "customer"; ddlsale.DataTextField = " Slarep"; //ddlsale second drop down name ddlcust1.DataBind(); // Bind the selected value in Drop down list //ddlsale.DataValueField = "um_Dealer_ReportingTo"; ddlsale.DataBind(); //Close the SqlDataReader dr.Close(); } } pls tell me correct syntax after correction

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Before software should be reusable, it should be usable.” - Ralph Johnson