473,804 Members | 3,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2402
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

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

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.It em || item.ItemType =
ListItemType.Al ternatingItem)
{
DropDownList list = item.FindContro l("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspa mming.com> wrote in message
news:AC******** *************** ***********@mic rosoft.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:DropDownLi st id="MyList" runat="server" />
<ItemTemplate>. ..

and in your postback handler you can use:
foreach (DataGridItem item in mygrid.Items)
{
if (item.ItemType = ListItemType.It em || item.ItemType =
ListItemType.Al ternatingItem)
{
DropDownList list = item.FindContro l("MyList") as DropDownList;
...
}
}

"Eric Dan" <no****@stopspa mming.com> wrote in message
news:AC******** *************** ***********@mic rosoft.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
3422
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 image, it does build up the image gradually until it's almost finished, but then the partly visible image is replaced by the error message/error box as described above. It seems like indexed <256cols pngs are not subject to this problem. I've read...
1
4172
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 displaying all the documentcollections(dynamic) in the Treestructure, In the Right side we are displaying all the HolderGroups (dynamic).We have to assing Any one of the Documentcollections to HolderGroups, through Drag and Drop
1
2070
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 won't overlay over the frame below. Is there any way round this?? I'm not a Javascript programmer, so any coding changes need to be fully explained please.
1
3008
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 missing? Thanks in advance........ --------------= Posted using GrabIt =---------------- ------= Binary Usenet downloading made easy =--------- -= Get GrabIt for free from http://www.shemes.com/ =-
0
482
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 program, but the ActiveX has no support for it, so trying to use it just causes error's. What i have done is use a small label that i use for displaying current progress in the media file to use the drag-and-drop functionality.
8
3306
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 picture. The ctrl in the form only displays the filename of the picture. The underlying table, when opened in table view, shows the word "package" in the field. When I double-click on either it opens the picture, but I can't get it to display. ...
9
2180
by: piyush2884 | last post by:
hi guys, got anything on this issue?
3
3382
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 way to use this exception and drop the 20000 bit... i've tried user defined and dbms_ouput but neither are captured by the app any ideas Thanks
10
5774
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 images) of the gridview come from a single table/datasource. Here is my situation. In my web application, I need to display customer bills info in a gridview. Customer names and contact info are from the Customer table.
0
1845
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 is coming for the tooltip but the arrow image in the tooltip is not displaying. I tried giving z-index property values but the arrow image is not displaying. I tried this with ie8. My css for tooltip .graphtooltip { display: none; padding:...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.