Need to set dropdownlist based on gridview selection
Hello Everyone,
I would like to know how to set dropdownlist values after selecting the gridview row.
I tried all the possibilities but it doesn't set to the selected value instead it always points to the initial item.
Below is my piece of code.
//ddlid.SelectedItem.Value = grdEmployee.SelectedRow.Cells[1].ToString();
// ddlname.SelectedItem.Value = grdEmployee.SelectedRow.Cells[3].ToString();
// txtSal.Text = grdEmployee.SelectedRow.Cells[4].Text;
Thanks in advance.
Abhay ShankerPosted Nov 26, 2013, 10:24 PM
do as below:-
1.add row command event
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
}
}
2.Inside row command at first call dropdownlidt bind method
3.Then select the value whatever you gridviewselected row returns