简体   繁体   中英

How to Pass gridview value in to another page Dropdown (How to change Dropdown selected value dynamically )

I have a grid view report view with EDIT link button. When I click the button, the page redirects to another update page with the CURRENT DATA from gridview. For Text box, it works fine, but I can't do the same for the drop-down.

I've tried this:

ddnAssinedBy.SelectedValue = gvAction.SelectedRow.Cells[3].Text;    
ddnAssinedBy.Items.FindByValue(gvAction.SelectedRow.Cells[3].Text).Selected = true;

But it is not working.

In your edit linkbutton event , get values you need and put them in session like

Session["current-selection"] =gvAction.SelectedRow.Cells[3].Text;

On another page use this value set selection in dropdown.

Another option is to pass value in query string when you redirect and fetch it on another page.

Try this

ddnAssinedBy. SelectedItem.Text = gvAction.SelectedRow.Cells[3].Text;

or

ddnAssinedBy.Items. FindByText (gvAction.SelectedRow.Cells[3].Text).Selected = true;

but first you have to disable selected item

ddnAssinedBy.SelectedItem.Selected= false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM