Click here to Skip to main content
15,919,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my run mode as follows


Gridview as follows;

Facid 1 2 3 4 5

1 dropdownlist1 dropdownlist2 dropdownlist3 dropdownlist4 dropdownlist5
(good/fair/poor) (good/fair/poor)(good/fair/poor) (good/fair/poor) (good/fair/poor)

2 dropdownlist6 dropdownlist7 dropdownlist8 dropdownlist9 dropdownlist10
(good/fair/poor) (good/fair/poor)(good/fair/poor) (good/fair/poor) (good/fair/poor)


i want to save the above gridview records in database.


In database table structure as follows

Facid R1 R2 R3 R4 R5

1 good fair good fair good
2 good fair good fair good

for that how can i do in asp.net using c#.
Posted
Comments
[no name] 8-Feb-14 4:38am    
please reply

Here is the solution. Please make the changes as per your requirement.

C#
using(SqlConnection connection = new SqlConnection(@"data source=ABC; persist security info=True;initial catalog=ini"))
{
    using(SqlCommand command = new SqlCommand(sql, connection))
    {
        try
        {
            connection.Open();
            for (int i =0; i< gridView1.RowCount; i++)
            {
                SqlParameter parameter = new SqlParameter();
                                parameter.ParameterName = "@Num";

                parameter.SqlDbType = SqlDbType.NVarChar;
                parameter.Direction = ParameterDirection.Input;
                parameter.Value = Convert.ToString(gridView1.GetRowCellValue(i, "Number"));


                command.Parameters.Add(parameter);
            }
            command.ExecuteNonQuery();
        }
        catch(Exception)
        {

        }

    }


}



Cheers,
Praveen Nelge
 
Share this answer
 
Here is the solution

link 1
link 2
 
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