Click here to Skip to main content
15,742,377 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want to bind the values that are selected in the dropdown into the gridview for the selected vales in the gridview. In my application I am using the gridview in that there are 5 columns and one column with check box, here I will select this check box and i am having an dropdown outside the gridview when I select the values in the dropdown and click the submit button, the values in the dropdown should be binded to selected checkbox row. Can any one help me to solve this issue.

Thanks in Advance

GridViewRow row = GridView1.Rows[e.RowIndex];
       string eno;

       eno = GridView1.DataKeys[e.RowIndex].Value.ToString();

       TextBox empname = (TextBox)row.FindControl("txtempname");
       DropDownList status = (DropDownList)row.FindControl("DropDownList1");
       string selval;

       if (status.SelectedValue == "Yes")
           selval = "Y";
           selval = "N";

       sqlcmd = new SqlCommand("update emp set empname='" + empname.Text + "',empstatus='" + selval + "' where eno='" + eno + "'",sqlcon);
       sqlcmd.CommandType = CommandType.Text;
       GridView1.EditIndex = -1;

check this link
Share this answer
Use the variable selectedValue as input paramater to your query.

string selectedValue = ddlCategory.SelectedValue;

I know you can do the query yourself :)

Mark this as correct answer if it solves your problem

Best regards.
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