C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Visual Studio »

The code to insert the textbox datas to datagridview


Posted Date: 15 Oct 2009      Posted By: Abinet      Member Level: Bronze     Points: 1   Responses: 2



I want to insert the data from the textbox to datagridview .
the first data is inserted but when i add another data in the grid view it replaces the existing data, i used dt.newrow but not working i think, so please show me the code to insert data from textbox to datagrid in a new row with out replacing the existing data so that when i click the insert button many rows would be created that is with out replacing the existing ones. thanks!





Responses

Author: seema    15 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi,

1. Call Fill on a TableAdapter or DataAdapter to populate a DataTable.
2. Bind the DataTable to your grid.
3. Add a new row to the DataTable with the data from your TextBoxes, which will automatically update the grid.
4. Call Update on a TableAdapter or DataAdapter to save the changes from the DataTable to the database.



Author: Alwyn    19 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

ok, i understood the cause of the error;

reason is,
in the click event, u r loading data into dataset and binding it to the grid. declare the dataset as global, this will work

Thanks & Regards,
Alwyn.
Jesus saves! The rest of us better make backups.



Post Reply
You must Sign In to post a response.
Next : Call a function
Previous : Which to buy
Return to Discussion Forum
Post New Message
Category: Visual Studio

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use