Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

add dataset items to listbox in c# asp.net (or) how to bind data in listbox in asp.net c#

In this post , I explained how to Bind data set values to list box.  I have used  stored procedures in this article.  Here  lbFunctions is my list box ID.




using System;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingTelerik.WinControls;
usingSystem.Data.SqlClient;
usingMicrosoft.ApplicationBlocks.Data;

namespace Company
{
    public partial class NamedFunctions : Telerik.WinControls.UI.RadForm
    {
  private void getNames()
        {
            try
            {
                SqlConnectioncon = new SqlConnection(”connectionString”);
                da = newSqlDataAdapter("Your_StoredProcedure_Name ", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                dsDetails = new DataSet();
                da.Fill(dsDetails, "Details");

                for(int i = 0; i < dsDetails.Tables[0].Rows.Count; i++)
                {
                    lbFunctions.Items.Add(dsDetails.Tables[0].Rows[i]["TABLE_FIELD_NAME"]);
                }
            }
            catch(Exception ex)
            {
            }
        }
 }
}




This post first appeared on Asp.netSourceCodes, please read the originial post: here

Share the post

add dataset items to listbox in c# asp.net (or) how to bind data in listbox in asp.net c#

×

Subscribe to Asp.netsourcecodes

Get updates delivered right to your inbox!

Thank you for your subscription

×