Click here to Skip to main content
15,916,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table with these columns:

id
Studentid
subjectid1
marks1
subjectid2
marks2
........
subjectid10
marks10
Total

I have a grid like this:

studentid subjectid1 subjectid2 subjectid1 Total
1 54(Marks) 74(Marks) 128

I want to insert this records, into database. I don't [know] number of subjects (number of columns in dgv)

Thanks in advance.
Posted
Updated 21-Feb-12 1:37am
v4

int DataGridView.ColumnCount Gets or sets the number of columns displayed in the DataGridView.

C#
int count = myGridView.ColumnCount;



http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.columncount(v=vs.80).aspx[^]
 
Share this answer
 
v2
Then You don't set the design of gridview just put a gridview and make queried and in side queries put all alies name and direct write

gridview1.datasource=ds.table[0];
gridview1.databind();


What I have understand from your question this may help you..
 
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