Trying to re assign selected items to a listbox from a dataset

I am trying to re assign what was previously selected into a list box
I am lost
I have this so far:
         protected void LoadRolesandGroups(int userid)
         {

             rlbActiveGroups.Items.Clear();
             rlbGroups.Items.Clear();
             rlbRoles.Items.Clear();
             rlbActiveRoles.Items.Clear();

             //DataTable dtGroups; //= helper.ExecuteProcDataTable("sp_Membership_GetAllGroupswithUser", "@useruid", userid);

 
            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                con.Open();
                //userid = user.UserID;
                iuserid = userUIDValue;
                SqlCommand com = new SqlCommand("sp_Membership_GetAllGroupswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                foreach(ListBox group in dsGroups)
                {
                this.rlbActiveGroups.DataSource = dsGroups;
                this.rlbActiveGroups.DisplayMember = "GroupDefDescription";
                    this.rlbActiveGroups.ValueMember = "GroupDefUID";
                }


               }

Open in new window

I relly could use the help
Thanks
R
LVL 6
r3nderAsked:
Who is Participating?
 
LIONKINGCommented:
I'm sorry, but I still don't understand why you're looping through the DataTable and assigning the entire datatable as a datasource to the list.

If you assign the entire datatable as a datasource to the list you're saying that "all" the content of the datatable should be the displayed in the list, therefore no need to loop.

If, on the other hand, you decide to loop through your datatable and evaluate a condition, you can just "add" items to the Items collection of the list.

If you want to avoid looping through the DataTable to evaluate your function "and you're not using that datatable anywhere else", you can filter out the results and assign the entire (filtered) datatable to the listBox.

Something like this:

try
            {
                int iuserid = 87;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsRoles = new DataSet();
                sqldba.Fill(dsRoles);
                dsRoles.Tables[0].DefaultView.RowFilter = "InRole = 1"; //<<-- Assuming it's a BIT column, if not, adjust accordingly
                lstActiveRoles.DataSource=dsRoles.Tables[0];
                lstActiveRoles.DisplayMember="RoleDefinition";
              }

Open in new window


P.S. Removed the commented lines to make it easier to read.

Please try it as it is and let us know.
0
 
LIONKINGCommented:
If you only want to add to the listbox the items that are returned in your query, this might help:

         protected void LoadRolesandGroups(int userid)
         {

             rlbActiveGroups.Items.Clear();
             rlbGroups.Items.Clear();
             rlbRoles.Items.Clear();
             rlbActiveRoles.Items.Clear();

             //DataTable dtGroups; //= helper.ExecuteProcDataTable("sp_Membership_GetAllGroupswithUser", "@useruid", userid);

 
            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                con.Open();
                //userid = user.UserID;
                iuserid = userUIDValue;
                SqlCommand com = new SqlCommand("sp_Membership_GetAllGroupswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                this.rlbActiveGroups.Items.Clear();
                foreach(DataRow myRow in dsGroups.Tables[0].Rows)
                {
                this.rlbActiveGroups.Items.Add(myRow[0].ToString());
                }


               }

Open in new window

0
 
r3nderAuthor Commented:
sorry didnt work - anymore ideas?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
r3nderAuthor Commented:
This has the values in it whenI go to debug and mouse over each I get there values but it wont write it to the listbox

            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //con.Open();
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                
                //this.rlbActiveGroups.Items.Clear();

                foreach (DataRow myRow in dsGroups.Tables[0].Rows)
                {
                    
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {
                        rlbActiveRoles.DisplayMember = myRow["RoleDefinition"].ToString();
                        rlbActiveRoles.ValueMember = myRow["roledefuid"].ToString();
                        //this.rlbActiveRoles.Items.Add(myRow[0].ToString());
                    }
                }

Open in new window

on a side note I do fill the 1st list box on page load - it is a pair of list boxes 1 is roles the other is selected roles - I am trying to fill the previously selected roles when the page loads to allow the user to update them
That code is
        public void fillRoles()
         {
             string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
             SqlConnection con = new SqlConnection(connectionString);
             try
             {
                 Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                 con.Open();
                 int userid = user.UserID;
                 SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                 com.CommandType = CommandType.StoredProcedure;
                 com.Parameters.AddWithValue("@Useruid", userid);
                 SqlDataAdapter sqldba = new SqlDataAdapter(com);
                 DataSet dsRoles = new DataSet();
                 sqldba.Fill(dsRoles);
                 dtRoles = dsRoles.Tables[0];
                 rlbRoles.DataSource = dtRoles;
                 rlbRoles.DisplayMember = "RoleDefinition";
                 rlbRoles.ValueMember = "Roledefuid";
                 dtActiveRoles = dsRoles.Tables[0].Clone();
                 rlbActiveRoles.DataSource = dtActiveRoles;
                 rlbActiveRoles.DisplayMember = "RoleDefinition";
                 rlbActiveRoles.ValueMember = "roledefuid";
                                  con.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 con.Close();
             }
         }

Open in new window

0
 
r3nderAuthor Commented:
DataTable dtActiveRoles
DataTable dtRoles
Are public Datatables and in defined at the begining of the page
P.S. I am all out of ideas....help please
0
 
LIONKINGCommented:
So the last code you posted is working?

If you're linking the listbox to the data source you don't need to do the foreach loop.
You can just assign the datatable as the datasource of the listbox, like the code you already have.

In the code I provided I assumed you had to loop through the datatable, but if you want to use the datatable as a datasource the foreach is not needed.

Let me know if you need assistance with adjusting your "working" code.
0
 
r3nderAuthor Commented:
Imagine aa user selecting 2 items in as list box and and transfering them to the next listbox. Then they close te app they come back and open the same app I want the ones they selected to appear in the second listbox just like they left it - I cant get it to do it
0
 
LIONKINGCommented:
But you're saving those two (selected) items in the database (or somewhere), right?
0
 
r3nderAuthor Commented:
yes - the code here
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //con.Open();
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                
                //this.rlbActiveGroups.Items.Clear();

                foreach (DataRow myRow in dsGroups.Tables[0].Rows)
                {
                    
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {
                        rlbActiveRoles.DisplayMember = myRow["RoleDefinition"].ToString();
                        rlbActiveRoles.ValueMember = myRow["roledefuid"].ToString();
                        //this.rlbActiveRoles.Items.Add(myRow[0].ToString());
                    }
                }

Open in new window


is retrieving  it to show in the selected roles listbox
0
 
r3nderAuthor Commented:
here is what I have tried so far
               foreach (DataRow myRow in dsActiveRoles.Tables[0].Rows.Cast<DataRow>().ToList())
               {
                   //lock (this) 
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {

 
 
                        dtActiveRoles.Rows.Add(myRow[0].ToString());
                        //this.rlbActiveRoles.DataSource = dtActiveRoles;
                        
                        //dtActiveRoles.Rows.Add((i));
                        //this.rlbActiveRoles.Items.Add(myRow[0].ToString());

                        this.rlbActiveRoles.DisplayMember = myRow[1].ToString();
                        this.rlbActiveRoles.ValueMember = myRow[0].ToString();
                        //this.rlbActiveRoles.Items.Add(myRow[0].ToString());
                        
                    }
                    //dtActiveRoles.AcceptChanges();
                }

Open in new window

0
 
LIONKINGCommented:
Can  you please try this:

            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //con.Open();
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                
                this.rlbActiveGroups.DataSource = dsGroups.Tables[0].DefaultView;
                this.rlbActiveGroups.DisplayMember = "RoleDefinition";

               }

Open in new window


If it doesn't work, can you please let us know what error is giving you, or what is it displaying.

Thanks,
0
 
r3nderAuthor Commented:
no error and did  not work selected role is still blank
Capture.PNG
0
 
LIONKINGCommented:
If you check this:

dsGroups.Tables[0].Rows.Count

Does it have something <> 0?
0
 
r3nderAuthor Commented:
Yes 120
Capture.PNG
0
 
LIONKINGCommented:
Are you sure you have no special properties modified, because I tried both the methods I gave you and they both work.

Example print screen
0
 
r3nderAuthor Commented:
here is the entire method:
        protected void LoadRolesandGroups(int userid)
         {
            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                con.Open();
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllGroupswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
                foreach (DataRow myRow in dsGroups.Tables[0].Rows)
                {
                    if (Convert.ToBoolean(myRow["InGroup"]))
                    {
                        this.rlbActiveGroups.Items.Add(myRow[0].ToString());
                        //dtActiveGroups.Rows.Add(myRow[0].ToString());
                        //this.rlbActiveGroups.DisplayMember = myRow[1].ToString();
                        //this.rlbActiveGroups.ValueMember = myRow[0].ToString();
                    }
                }

 
               }
            
            catch (Exception exLoadRolesandGroups)
            {
                con.Close();
                MessageBox.Show(exLoadRolesandGroups.InnerException.ToString());
            }
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsActiveRoles = new DataSet();
                sqldba.Fill(dsActiveRoles);
                int count = dsActiveRoles.Tables[0].Rows.Count;
                MessageBox.Show(count.ToString());
               foreach (DataRow myRow in dsActiveRoles.Tables[0].Rows.Cast<DataRow>().ToList())
               {
                   //lock (this) 
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {
                        this.rlbActiveGroups.DataSource = dsActiveRoles.Tables[0].DefaultView;
                        this.rlbActiveGroups.DisplayMember = "RoleDefinition";
                        this.rlbActiveRoles.ValueMember = "rolefeduid";
                     }
                    //dtActiveRoles.AcceptChanges();
                }
            }
            catch (Exception exLoadRolesandGroups)
            {
                con.Close();
                MessageBox.Show(exLoadRolesandGroups.InnerException.ToString());
            }
         }

Open in new window

0
 
r3nderAuthor Commented:
the only special event i have is doubleclick so that you can move one value from 1 box to the other with out clicking the button (double click the displaymember in the first listbox
0
 
LIONKINGCommented:
I think the second part (second try) of your code is where you're having problems, right?
I see that you're looping through the rows and evaluating a field. If you do this, you shouldn't assign the DataSource to the listbox. Instead you can use the listbox.items.add method.

My first guess would be that there are no records that meet your criteria, that's why it's always empty.
Can you please try this code that follows, and place a BreakPoint in the first line inside the if, the one that I've highlighted with a comment.

if the program doesn't stop, that means that there are no rows meeting the criteria you're evaluating.

try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsActiveRoles = new DataSet();
                sqldba.Fill(dsActiveRoles);
                int count = dsActiveRoles.Tables[0].Rows.Count;
                MessageBox.Show(count.ToString());
               foreach (DataRow myRow in dsActiveRoles.Tables[0].Rows.Cast<DataRow>().ToList())
               {
                   //lock (this) 
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {
                        this.rlbActiveGroups.Items.Add(myRow["RoleDefinition"].ToString()) // <<-- Place breakpoint on this line
                     }
                    //dtActiveRoles.AcceptChanges();
                }
            }
            catch (Exception exLoadRolesandGroups)
            {
                con.Close();
                MessageBox.Show(exLoadRolesandGroups.InnerException.ToString());
            }

Open in new window

0
 
r3nderAuthor Commented:
Stopped and nothing -sorry I am at a loss
Capture.PNG
Capture1.PNG
0
 
r3nderAuthor Commented:
It is a checked listbox if that  matters
0
 
LIONKINGCommented:
I even tried replacing the control with a CheckedListBox, it still works fine in my end.
I'm sorry, but I think I'm out of ideas...

If you want to know if it's the control that's bugging you, you might want to change the name of the list box(only in that part of the program) and fill the first (left hand) listbox with the selected roles. Maybe it's some property at design time that was modified.

I'm sorry, but I've tried everything I've told you and it works on my side. So I guess it's something other than the code.

Let us know.
0
 
r3nderAuthor Commented:
Thanks for the help - I do appreciate it - well....Back to the drawing board
0
 
LIONKINGCommented:
Did you try switching the names? Still the same result?
0
 
r3nderAuthor Commented:
I renamed and added a datatable and changed the name of the dataset and now I got an error
"Child list for field System could not  be created"
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //iuserid = user.UserID;//User (or manager) UID
                iuserid = userUIDValue;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsNewActiveRoles = new DataSet();

                sqldba.Fill(dsNewActiveRoles);
                DataTable dtNewActiveRoles = dsNewActiveRoles.Tables[0];

                
               
                foreach (DataRow myRow in dsNewActiveRoles.Tables[0].Rows)
               {
                   //lock (this) 
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {

                        //dtRoles.Rows.Remove(drActiveRoles);
                        dtNewActiveRoles.Rows.Add(myRow.ItemArray);
                        rlbActiveGroups.DataSource = dtNewActiveRoles;
                        rlbActiveGroups.DisplayMember = dtNewActiveRoles.Rows[1].ToString();
                        rlbActiveGroups.ValueMember = dtNewActiveRoles.Rows[0].ToString();

 
                     }
                    //dtActiveRoles.AcceptChanges();
                }
            }
            catch (Exception exLoadRolesandGroups)
            {
                con.Close();
                MessageBox.Show(exLoadRolesandGroups.Message.ToString());
            }

Open in new window

0
 
rajeeshmcaCommented:
Hi,

try the following code..

 protected void LoadRolesandGroups(int userid)
         {

             rlbActiveGroups.Items.Clear();
             rlbGroups.Items.Clear();
             rlbRoles.Items.Clear();
             rlbActiveRoles.Items.Clear();

             //DataTable dtGroups; //= helper.ExecuteProcDataTable("sp_Membership_GetAllGroupswithUser", "@useruid", userid);

 
            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                con.Open();
                //userid = user.UserID;
                iuserid = userUIDValue;
                SqlCommand com = new SqlCommand("sp_Membership_GetAllGroupswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsGroups = new DataSet();
                sqldba.Fill(dsGroups);
               
                this.rlbActiveGroups.DataSource = dsGroups;
                this.rlbActiveGroups.DisplayMember = "GroupDefDescription";
                    this.rlbActiveGroups.ValueMember = "GroupDefUID";
                 this.rlbActiveGroups.Databind();

               }

This is the same code u have posted. I have removed the for loop and added the Databind() method....

Regards
Rajeesh
0
 
r3nderAuthor Commented:
ok I built a new 1 and it binds each column to a row
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.SqlClient;
using System.Configuration;
using Sentry;
using Sentry.Security;
using System.Web;
namespace testlistbox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void MoveListBoxItems(ListBox source, ListBox destination)
        {
            ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
            foreach (var item in sourceItems)
            {
                destination.Items.Add(item);
            }
            while (source.SelectedItems.Count > 0)
            {
                source.Items.Remove(source.SelectedItems[0]);
            }
        } 


        private void btnTo_Click(object sender, EventArgs e)
        {
            MoveListBoxItems(lstRoles, lstActiveRoles);
        }

        private void btnFrom_Click(object sender, EventArgs e)
        {
            MoveListBoxItems(lstActiveRoles, lstRoles);

        }

        public void fillRoles()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                //Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                con.Open();
                int userid = 87;
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Useruid", userid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsRoles = new DataSet();
                sqldba.Fill(dsRoles);
                DataTable dtRoles = dsRoles.Tables[0];
                lstRoles.DataSource = dtRoles;
                lstRoles.DisplayMember = "RoleDefinition";
                lstRoles.ValueMember = "Roledefuid";
                //rlbGroups.ValueMember = "RoleID"; <--make these hidden text fields
                DataTable dtActiveRoles = dsRoles.Tables[0].Clone();
                lstActiveRoles.DataSource = dtActiveRoles;
                lstActiveRoles.DisplayMember = "RoleDefinition";
                lstActiveRoles.ValueMember = "roledefuid";
                //rlbActiveGroups.ValueMember = "Roledefuid";<--make these hidden text fields
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                con.Close();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            fillRoles();
            LoadRolesandGroups(87);
        }
        protected void LoadRolesandGroups(int userid)
        {

            string connectionString = ConfigurationManager.ConnectionStrings["TaskManager"].ToString();
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                //Sentry.Security.KKMembershipUser user = KKPlmData.User.Get(false);
                //con.Open();
                //iuserid = user.UserID;//User (or manager) UID
                int iuserid = 87;// Selected agent UID
                SqlCommand com = new SqlCommand("sp_Membership_GetAllRoleswithUser", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useruid", iuserid);
                SqlDataAdapter sqldba = new SqlDataAdapter(com);
                DataSet dsRoles = new DataSet();
                sqldba.Fill(dsRoles);
                foreach (DataRow myRow in dsRoles.Tables[0].Rows)
                {
                    if (Convert.ToBoolean(myRow["InRole"]))
                    {
                    this.lstActiveRoles.DataSource = myRow.ItemArray;
                    this.lstActiveRoles.DisplayMember = myRow["RoleDefinition"].ToString();
                    this.lstActiveRoles.ValueMember = myRow["roledefuid"].ToString();
                    
                    
                    }
                }

              }



                //foreach (DataRow myRow in dsNewActiveRoles.Tables[0].Rows)
                //{
                //    //lock (this) 
                //    if (Convert.ToBoolean(myRow["InRole"]))
                //    {
                //        //dtRoles.Rows.Remove(drActiveRoles);
                //        //dtNewActiveRoles = null;
                //        //lstActiveRoles.DataSource = null;
                //        //dtNewActiveRoles.Rows.Add(myRow.ItemArray);
                //        //lstActiveRoles.DataSource = myRow[0];
                //        lstActiveRoles.DisplayMember = myRow[1].ToString();
                //        lstActiveRoles.ValueMember = myRow[0].ToString();


                //    }
                    //dtActiveRoles.AcceptChanges();
                //}
        //}
            catch (Exception exLoadRolesandGroups)
            {
                con.Close();
                MessageBox.Show(exLoadRolesandGroups.Message.ToString());
            }
        }
  
}
}

Open in new window

and gives a complex databinding error
0
 
r3nderAuthor Commented:
worked like a champ !!! Thanks man!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.