dropdownlist in a datagrid - allow for no value to be selected



I'm using TemplateColumns in a datagrid to allow a record to be edited. The
record contains several columns that are dropdownlists that pull from
"dictionary/ code-decode" tables. However, these columns are NOT required
in the underlying table. Given that I'm using TemplateColumns, what is the
best way to allow a user to leave the drop down list unselected? Or is
there another approach I should be taking?

Thanks in advance!

<asp:TemplateColumn HeaderText="Rank">
<asp:Label id="lblRank" Text='<%# DataBinder.Eval(Container,
"DataItem.rank_descr")%>' Runat="server"/>
<asp:DropDownList id="ddlrank" Runat="server" DataValueField="rank_cd"
DataTextField="rank_descr" DataMember="rank_cd" DataSource="<%#
GetRankTable() %>"/>



Corey Wineman

There may be better ways, but what I have done is insert an item at the
beginning of the dropdownlist. Something like "(Select)". If they haven't
selected anything, the selected index will point to the placeholder
"(Select)" item. Then in the code-behind when I am looking for changes, I
just look to see if they have picked something other than the placeholder.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question