Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application have folling method. I wants to bind ListView using this method. please help

C#
[DataObjectMethod(DataObjectMethodType.Select)]
        public static List<distribution> GetDistribution()
        {
            MySqlCommand cmd = new MySqlCommand("ShowDistribution", new MySqlConnection(GetConnectionString()));
           // cmd = new OdbcCommand("ShowDistribution", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection.Open();
                     
            MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

           

            List<distribution> Distributionlist = new List<distribution>();
            while (dr.Read())
            {
                Distribution di = new Distribution();
                di.voiceno = Convert.ToString(dr["voiceno"]);
                di.Accountname = Convert.ToString(dr["Accountname"]);
                di.Dictation = Convert.ToString(dr["Dictation"]);
                di.jobprioriety = Convert.ToString(dr["jobprioriety"]);
                di.Jobtype = Convert.ToString(dr["Jobtype"]);
                di.status1 = Convert.ToString(dr["status1"]);

                
            }
           
            dr.Close();
            return Distributionlist;
        }
Posted
Updated 24-Aug-11 22:36pm
v4

1 solution

Unfortunately the ListView does not provide for complex data binding in a way such as, for example, a DataGridView does.
However, here is an article that might get you started: Data binding a ListView[^].
Alternatively you might try to use another Control such as DataGridView, which can simply bind to any List of Objects by assigning it to the DataSource Property.
 
Share this answer
 

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