Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Gridview Records as follows


Roomno Course Roomno Course


11 MFA(dropdownlist) 21 EFA(dropdownlist)

12 RM(dropdownlist) 22 REO(dropdownlist)

13 SAC(dropdownlist) 23 PH2(dropdownlist)


In dropdownlist all the course are retrieve from the database and displayed in the all the dropdownlist.


Out of 6 Roomno suppose user want to change the Particular three roomno.

For example Roomno 11,21,23 Course has changed as follows


11 PH1
21 ARPA
23 ECDIS


with single click of button i want to update.


for that how can i do using csharp.
Posted

try this on your Update Button Click
C#
int i = 0;
            int j = 0;
            con = new OleDbConnection("YourConnectionString");//Which ever connection you are using
            con.Open();
            while (i < dataGridView1.Rows.Count)
            {
                string str = "update YourTableName set YourColumnName='" + dataGridView1.Rows[1].Cells[i].Value + "' where RommNo='" + dataGridView1.Rows[0].Cells[i].Value + "'";//you update query
                cmd = new OleDbCommand(str(), con);
                cmd.ExecuteNonQuery();
                i += 1;
            }
            i = 0;
            while (i < DataGridView1.Rows.Count)
            {
                str() = "update YourTableName set YourColumnName='" + dataGridView1.Rows[3].Cells[i].Value + "' where RommNo='" + dataGridView1.Rows[2].Cells[i].Value + "'";//Your update query
                cmd = new OleDbCommand(str(), con);
                cmd.ExecuteNonQuery();
                i += 1;
            }
 
Share this answer
 
Are you looking for something like this.

Bulk Edit Update Delete in Gridview[^]

Regards.. :laugh:
 
Share this answer
 
Comments
[no name] 9-Jul-13 4:31am    
please reply how can i do using csharp.
how to update the mutiple gridview rows using dropdownlist with single click of button.

please help me.
Rgds,
Narasiman P.
Thanks7872 9-Jul-13 4:51am    
Its there C# as well as VB are there.Why dont you go through the links that are provided?

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