Click here to Skip to main content
15,887,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am looking for a solution i given my code below when i added static item on the checked list box and selecting a item i am getting the item on the message box is like "Some listbox value" But with the same code when i am binding checked list box from the database value i am getting the message box value is System.Data.DataRowView what should i do to get the solution anybody help me

What I have tried:

private void button1_Click(object sender, EventArgs e)
    {
        foreach (object s1 in ChGetQtnNumber.CheckedItems)
        {
            string getdetailofQtn = s1.ToString();
            MessageBox.Show(getdetailofQtn);
        }
    }
Posted
Updated 13-Dec-18 1:54am
Comments
[no name] 13-Dec-18 7:27am    
Try with MessageBox.Show(getdetailofQtn.ToString();
Sherif Clemnt 15-Dec-18 0:21am    
i tried this

1 solution

DataRow does not implement ToString, because it can't tell which cell or sells you want to look at! As a result, ToString calls the default object implementation which returns the name of the type "System.Data.DataRow".
Instead of using ToString, get the column data from the row:
C#
string getdetailofQtn = "";
DataRow dr = s1 as DataRow;
if (dr != null && dr.ItemArray.Length > 0)
   {
   getdetailofQtn = dr[0].ToString();
   }
else
   ...
 
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