Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Every One,

I am working in a project in C#. In Which I am show records in gridview.
In a column of gridview i use a radio button in a column of gridview.

I want that user may be select more than one row's radio buttons.
and after that he will be save that records so i want to know that please tell me a code by which when i will save recirds then less time will be consume.

now i am using an insert query in stored procedure to insert a single record at a time
so in the above situation what code will be use.

please tell me.
Posted

You can use this

C#
protected void btnSubmit_Click(object sender, EventArgs e)
        {	
	    
            foreach (GridViewRow gr in GridView1.Rows)
            {
                Label lbl = (Label)(gr.Cells[8].FindControl("Label4")); 
                RadioButton R1 = (RadioButton)(gr.Cells[7].FindControl("RD1")); 
                RadioButton R2 = (RadioButton)(gr.Cells[7].FindControl("RD2"));
                RadioButton R3 = (RadioButton)(gr.Cells[7].FindControl("RD3"));
                DropDownList ddL = (DropDownList)(gr.Cells[6].FindControl("DropDownList1"));
                HiddenField dd1 = (HiddenField)gr.Cells[6].FindControl("lblddl");
                if (R2.Checked == true)
                {
                    if (dd1.Value != "")
                    {
                        {
				//update query		
                        }
                        
                    }
                }

                if (R3.Checked == true)
                {
                    if (dd1.Value != "")
                    {
                        {
				//update query		
                        }
                        
                    }
                }

            }

Here lbl stores the ID where is used in the update query for condition.
 
Share this answer
 
v2
C#
protected void btnSubmit_Click(object sender, EventArgs e)
        {	
	    
            foreach (GridViewRow gr in GridView1.Rows)
            {
                Label lbl = (Label)gr.FindControl("Label4"); 
                RadioButton R1 = (RadioButton)gr.FindControl("RD1"); 
                
                RadioButton R3 = (RadioButton)gr.FindControl("RD3");
                DropDownList ddL = (DropDownList)gr.FindControl("DropDownList1");
               
                if (R1.Checked == true)
                {
                    if (dd1.Value != "")
                    {
                        {
				//update query		
                        }
                        
                    }
                }
 
                if (R3.Checked == true)
                {
                    if (dd1.Value != "")
                    {
                        {
				//update query		
                        }
                        
                    }
                }
 
            }
 
Share this answer
 
v2

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