Discussion:
ropdownlist selected index remains zero
(too old to reply)
Harsha
15 years ago
Permalink
Hi,

I have a ModalPopupExtender in my page. And In popup I am showing a
gridview. Inside Gridview a dropdownlist is there.

In pop there is a submitt button. But problem is in dropdownlist selected
index remains zero irespective of my selection.Even after I select
second,third or fourth Item ti will show first item of the dropdown as the
selected Item. Please help.

Please let me know why dropdownlist selected item is not getting changed ?
Also all my code in Page_load is inside if (!IsPostBack).

My Code is as below.

binding gridview in the popup:-

# protected void btnSearch_Click(object sender, EventArgs e)
# {
# DataTable dtContract = new DataTable();
# dtContract = objBLTimesheet.RunQuery(query);
#
#
# gvOrders.DataSource = dtContract;
# gvOrders.DataBind();
# }

And I am binding dropdownlist inside Gridview at RowDataBound Event as below:-

1. protected void gvOrders_RowDataBound(object sender,
GridViewRowEventArgs e)
2. {
3. if (e.Row.RowType == DataControlRowType.DataRow)
4. {
5. string Ordrno = rw.Cells[0].Text;
6. string query = "select MCSRLNO,FOORD from mccommdata";
7. DataTable dtmcslorder = new DataTable();
8. dtmcslorder = objBLTimesheet.RunQuery(query);
9. if (dtmcslorder.Rows.Count > 0)
10. {
11.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataSource = dtmcslorder;
12.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataTextField = "MCSRLNO";
13.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataValueField = "FOORD";
14.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataBind();
15.
16. }
17.
18. }
19. }
Alexey Smirnov
15 years ago
Permalink
...
Did you find the problem? You code doesn't show where you do the
submit. It might be that you
rebind gvOrders again...

Loading...