Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i need help in displaying folder contents in gridview in which data will NOT be constant.after displaying contents add 3 fields sequence,format,delay to the same grid which will be editable & user can insert update delete and save all this data in database.

problem is not able to save data from user input for sequence & delay and everything must be displayed in one gridview no buttons,lables,textbox nothing hence on which event what should be done and how to save user input data?

What I have tried:

Here is my code for displaying folder contents:

C#
DataTable table = new DataTable();
table.Columns.Add("File Name");
table.Columns.Add("Sequence");
table.Columns.Add("Delay");

for (int i = 0; i < files.Length; i++) {
    FileInfo file = new FileInfo(files[i]);
    table.Rows.Add(file.Name);
}
dataGridView1.DataSource = table;
Posted
Updated 2-Feb-17 1:46am
v3
Comments
Richard MacCutchan 2-Feb-17 5:10am    
What is the problem?
NazneenSayed 2-Feb-17 7:02am    
not able to save data from user input for sequence & delay and everything must be displayed in one gridview no buttons,lables,textbox nothing hence on which event what should be done and how to save user input data?
CHill60 2-Feb-17 7:07am    
What have you tried already to do all of that?
NazneenSayed 2-Feb-17 7:23am    
i tried creating a function and through that update and delete but now as there is no primary key and everything must be at runtime after displaying data from a particular folder i am literally stuck.
Richard MacCutchan 2-Feb-17 7:45am    
So what aspects of managing a database do you have a problem with?

1 solution

From the comments it would appear that you are not allowed another control for the User to decide when to save the data from the dataGridView.

This leaves you with only a few choices of when you can update the database.

I suggest doing the initial inserts/updates when you populate the datagridview. Any user edits could be done in the RowValidated event (or at a push the CellValidated event.

Note this is validated not validating

I don't understand your comment about primary key and there is insufficient information in the question to help you further. Do come back if you run into problems with the insert/update code but you will have to use the Improve question link to share that code.
 
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