A
AlBruAn
I have an application I'm working on in which I'm wanting to default to
displaying the previously selected value from a dropdownlist whenever the
user opts to edit a record in the datagrid control. I'm able to grab the
previously selected value from the text box, but I can't set the
SelectedValue in the corresponding dropdownlist equal to it. Code is as
follows:
458 Control ctl;
459 DataGridItem dgRow = e.Item;
460
461 ctl = e.Item.FindControl("lblFlooring");
462 currFlooring = ((Label)ctl).Text;
463
464 DataGrid1.EditItemIndex = e.Item.ItemIndex;
465 BindGrid();
466
467 ((DropDownList)dgRow.FindControl("ddlFlooring")).SelectedValue =
currFlooring;
When I attempt to execute line 467 in this code, I get the standard ""Object
reference not set to an instance of an object." message. BTW, lblFlooring is
the label containing the flooring material prior to entering the Edit mode
and ddlFlooring is the dropdownlist containing flooring materials once a row
has been placed in Edit mode. Anyway, is there another way of setting the
SelectedValue as part of the datagrid's EditCommand function? Any help would
be greatly appreciated.
displaying the previously selected value from a dropdownlist whenever the
user opts to edit a record in the datagrid control. I'm able to grab the
previously selected value from the text box, but I can't set the
SelectedValue in the corresponding dropdownlist equal to it. Code is as
follows:
458 Control ctl;
459 DataGridItem dgRow = e.Item;
460
461 ctl = e.Item.FindControl("lblFlooring");
462 currFlooring = ((Label)ctl).Text;
463
464 DataGrid1.EditItemIndex = e.Item.ItemIndex;
465 BindGrid();
466
467 ((DropDownList)dgRow.FindControl("ddlFlooring")).SelectedValue =
currFlooring;
When I attempt to execute line 467 in this code, I get the standard ""Object
reference not set to an instance of an object." message. BTW, lblFlooring is
the label containing the flooring material prior to entering the Edit mode
and ddlFlooring is the dropdownlist containing flooring materials once a row
has been placed in Edit mode. Anyway, is there another way of setting the
SelectedValue as part of the datagrid's EditCommand function? Any help would
be greatly appreciated.