TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
habib ullah
NA
229
14.2k
how to save the datagraidview selected rows in database
Apr 14 2018 10:03 AM
how to save the datagraidview selecter rows save in database if some rows checked in the grid
they insert the only one record in database pleas help me i am beginner
private void button1_Click(object sender, EventArgs e)
{
bool ReturnStatus = true;
String ReturnMessage = "";
//int ClassId =1;
try
{
//call function to save the data in database...
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
if ((bool)dataGridView1.Rows[i].Cells["chk"].Value == true)
{
List<SqlParameter> PRM = new List<SqlParameter>();
PRM.Add(new SqlParameter() { ParameterName = "@ClassName", Value = tbx_classname.Text });
PRM.Add(new SqlParameter() { ParameterName = "@Subject_Id", Value =dataGridView1.Rows[i].Cells["id"]});
PRM.Add(new SqlParameter() { ParameterName = "@TotalMarks", Value = dataGridView1.Rows[i].Cells["TotalMarks"]});
PRM.Add(new SqlParameter() { ParameterName = "@PassingMarks", Value = dataGridView1.Rows[i].Cells["PassingMarks"]});
rp.dbManage("[School].[CreateClass]", PRM, out ReturnStatus,out ReturnMessage);
MessageBox.Show(ReturnMessage.ToString());
}
}
Reply
Answers (
1
)
How to Display folders and sub folders in the Grid View C#
Open files in Grid view