C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






adding data from dataset to listview...


Posted Date: 18 Mar 2008    Resource Type: Code Snippets    Category: Databinding

Posted By: Roopesh Babu Valluru       Member Level: Gold
Rating:     Points: 10



Many ppl dont know abt using the list view and adding data from listview from dataset...first u have to set few properties like this...

VIEW to Details
FullRowSelect to True
GridLines to True

then add the column names u want to display using columns property...

in this code m_dsMain is DATASET with DATA...and lvwMain is my LISTVIEW...



try
{
if(m_dsMain != null)
{
if(m_dsMain.Tables.Count > 0)
{
if(m_dsMain.Tables[0].Rows.Count > 0)
{
for(int i = 0; i < m_dsMain.Tables[0].Rows.Count; i++)
{
ListViewItem l_lvwItem = lvwMain.Items.Add(m_dsMain.Tables[0].Rows[i]["BookingNumber"].ToString().Trim());
l_lvwItem.Tag = m_dsMain.Tables[0].Rows[i]["BookingID"].ToString().Trim();
l_lvwItem.SubItems.Add(m_dsMain.Tables[0].Rows[i]["AgentName"].ToString().Trim());
l_lvwItem.SubItems.Add(m_dsMain.Tables[0].Rows[i]["contactperson"].ToString().Trim());
l_lvwItem.SubItems.Add(m_dsMain.Tables[0].Rows[i]["phone1"].ToString().Trim());
l_lvwItem.SubItems.Add(m_dsMain.Tables[0].Rows[i]["mobile"].ToString().Trim());
l_lvwItem.SubItems.Add(m_dsMain.Tables[0].Rows[i]["email"].ToString().Trim());
}
}
}
}
}
catch(Exception ex)
{
g_objEX.Publish(ex);
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Remove ad Merge a row in DataTable if the row already exists
Previous Resource: Fill a DropDownList with files in a directory using c#
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it help desk

Contact Us    Privacy Policy    Terms Of Use