C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Training   ASP.NET Web Hosting    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

Play Silverlight Games or Submit your Silverlight applications and earn 90% AdSense revenue.

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




Forums » .NET » ASP.NET »

Avoiding duplicate entries in datagrid


Posted Date: 10 Jan 2009      Posted By: Cathrin      Member Level: Gold     Points: 1   Responses: 2



Hi,

I have a datagid with columns Category ,Subcategory and weightage.On Clicking a button the values entered in textboxes and values selected in dropdownLists gets entered in Datagrid.On Clicking a submit buttton data entered in datagrid gets stored in database.
My requirement is that i should not have same category twice in the datagrid.I create a datatable and that is set as datasource to datagrid.
Could anybody help me out?





Responses

Author: Pascal    10 Jan 2009Member Level: GoldRating:     Points: 2

I think we can loop thru the rows in the existing datatable with some rows in it to check if the category already exists before adding the new row to the existing datatable. If exists then dont add the row to the datatable. Else add it and refresh the datagrid.


Author: syed shakeer hussain     10 Jan 2009Member Level: DiamondRating:     Points: 2

Hi..
U can use Distinct Keyword in sql Query

SqlDataAdapter adapter=new SqlDataAdapter("SELECT DISTINCT column_name
FROM table_name",conn);
.
.
.
.
DataGrid1.DataSource=ds.Tables["tablename"];

You will not get repeated values in datagrid



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Multiview... property of a control
Previous : Ajax extender.
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use