473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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!
Mark

<asp:TemplateColumn HeaderText="Rank">
<ItemTemplate>
<asp:Label id="lblRank" Text='<%# DataBinder.Eval(Container,
"DataItem.rank_descr")%>' Runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id="ddlrank" Runat="server" DataValueField="rank_cd"
DataTextField="rank_descr" DataMember="rank_cd" DataSource="<%#
GetRankTable() %>"/>
</EditItemTemplate>
</asp:TemplateColumn>
Nov 17 '05 #1
1 1272
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.

"Mark" <fi**************@umn.edu> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
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!
Mark

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


Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
3
by: mg | last post by:
I have a DataGrid (WebForm - C#) that has a template column that contains a dropdownlist named "DdlTest" In DataGrid1_UpdateCommand, the lin DropDownList ddlTest = (DropDownList)...
1
by: m3ckon | last post by:
Hi there, please help if you can, I'm having an issue with droponnlists in a datagrid I have a datagrid which is populated from a query .. all works fine I've added two extra columns, one...
6
by: VB Programmer | last post by:
I have an itemtemplate in a datagrid. I'm trying to set it's value based on data. Having no trouble with the textbox. But, how do I do the same thing for a dropdownlist???? <ItemTemplate>...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
3
by: Jeff | last post by:
I have added a dropdownlist to an editable datagrid to allow a user to select Yes or No: <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "reports") %>'...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
2
by: =?Utf-8?B?VmljdG9yaW91czE=?= | last post by:
When the editcommand is execured for my datagrid the dropdown list appears for the bound item status. However, the item selected by default does not match the unedited data. How do I make the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.