473,396 Members | 1,671 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,396 software developers and data experts.

Displaying drop-down list boxes for every row in a DataGrid \ Repe

Hi,

Even tough I was able to implement what I want in a weird and non efficient
way, I would like to get an opinion what is the right way to achieve my task:

Scenario:
• Display a DataGrid that contains rows from a table from a databse (so far
easy).
• I would like to add a column to the DataGrid that will be a drop-down list
so the user will be able to select a value from a pre-defined list of values
for every row in the DataGrid. (every row should have a drop-down)
• When the user will post back the form I would like to refer to every value
in the drop-down list by name.
• In order to implement this I used a TemplateColumn in the DataGrid, but I
had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select> elements.
This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each and
every row in the data grid.

Any opinions?

--
Thanks
Eric
Nov 19 '05 #1
2 2378
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

<asp:datagrid id="mygrid"
....
<ItemTemplate>
<asp:DropDownList id="MyList" runat="server" />
<ItemTemplate>...

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.Item || item.ItemType =
ListItemType.AlternatingItem)
{
DropDownList list = item.FindControl("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspamming.com> wrote in message
news:AC**********************************@microsof t.com...
Hi,

Even tough I was able to implement what I want in a weird and non efficient way, I would like to get an opinion what is the right way to achieve my task:
Scenario:
. Display a DataGrid that contains rows from a table from a databse (so far easy).
. I would like to add a column to the DataGrid that will be a drop-down list so the user will be able to select a value from a pre-defined list of values for every row in the DataGrid. (every row should have a drop-down)
. When the user will post back the form I would like to refer to every value in the drop-down list by name.
. In order to implement this I used a TemplateColumn in the DataGrid, but I had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select> elements. This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each and every row in the data grid.

Any opinions?

--
Thanks
Eric

Nov 19 '05 #2
Thanks a lot

It is definitely the best solution

Eric

"Jakub" wrote:
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

<asp:datagrid id="mygrid"
....
<ItemTemplate>
<asp:DropDownList id="MyList" runat="server" />
<ItemTemplate>...

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.Item || item.ItemType =
ListItemType.AlternatingItem)
{
DropDownList list = item.FindControl("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspamming.com> wrote in message
news:AC**********************************@microsof t.com...
Hi,

Even tough I was able to implement what I want in a weird and non

efficient
way, I would like to get an opinion what is the right way to achieve my

task:

Scenario:
. Display a DataGrid that contains rows from a table from a databse (so

far
easy).
. I would like to add a column to the DataGrid that will be a drop-down

list
so the user will be able to select a value from a pre-defined list of

values
for every row in the DataGrid. (every row should have a drop-down)
. When the user will post back the form I would like to refer to every

value
in the drop-down list by name.
. In order to implement this I used a TemplateColumn in the DataGrid, but

I
had a hard time giving a name to the <select> element so I will be able to
refer to it when the form will be posted back. I have used a weird syntax
(with data binding syntax since the container is not the DataGrid but a
DataGrid item) to create a unique name for each one of the <select>

elements.
This caused the Design-View in Visual Studio to not be able to display the
page even though it did work at run time.
Somehow I feel that I took the wrong way to display a drop-down for each

and
every row in the data grid.

Any opinions?

--
Thanks
Eric


Nov 19 '05 #3

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

Similar topics

2
by: Xiao Tencas | last post by:
When trying to load a png image in GD, I get the error (Mozilla Firefox) "cannot display image, because it contains errors"; IE just shows an empty 'image-error' box. When loading a large enough...
1
by: srikanth | last post by:
Hi all, I have an requirement in one of my projects. We have one aspx page, in that we have two frames, in each frame having a tree structure control(dynamic data). In the left Frame we are...
1
by: Richard | last post by:
I have a framed page, with a 100 pixel deep header section. I've coded the JSCookMenu in that frame, but the drop downs get cut in half ..... ie. the drop downs only display within that frame and...
1
by: buzz | last post by:
I've created a simple table with text and images(gif, jpg) in a user control. Everything displays correctly in the designer. But when I drop the control on the main page, no images display. What am I...
0
by: ViRi | last post by:
I am currently experimenting a bit with AxMicrosoft.MediaPlayer.Intero­p.AxWindowsMediaPlayer and so far, most has gone well. Currently, i would like to add drag-and-drop functionality to the...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
9
by: piyush2884 | last post by:
hi guys, got anything on this issue?
3
by: cmc12 | last post by:
Hi, I'm raising an error from the dB to an Application like theis RAISE_APPLICATION_ERROR(-20000, 'Contact Support'); the thing is the error printed on screen contains the -20000, is there any...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
0
by: nataraj jaideep | last post by:
Hi, I want to apply drop shadow for my tooltip. If i give the below script--> filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000'); to my css, the drop shadow...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.