I have created a few DropDownLists that get populated with data from a database. The first lines of the Dropdownlists are ListItem
:
<asp:DropDownList ID="ddlChange_Requestor" runat="server" AppendDataBoundItems="True" CssClass="ddlChange_Requestor">
<asp:ListItem>Change Requestor</asp:ListItem>
I also have a GridView that has a RowCommand event on Select button.
When I press Select the DropDownLists will get back whatever value that the respected column/row has:
protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
{
{
GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);
txtActivity.Text = row.Cells[2].Text;
ddlChange_Requestor.SelectedValue = row.Cells[10].Text;
}
}
This works when Change Request column/row in the GridView has value but not when it's "white-space" / "Empty" / "Null". I do not really know how to fix it?
I would like to be able to do something like:
ddlChange_Requestor.SelectedValue = isnullOrwhitespace(row.Cells[10].Text , "Change Requestor");
However I would only want this in the background because I would like to have empty row in GridView but on RowCommand Select should understand that empty means ListItem
value.
Is this possible?