Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Displaying drop-down list boxes for every row in a DataGrid \ Repe

Reply
Thread Tools

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

 
 
=?Utf-8?B?RXJpYyBEYW4=?=
Guest
Posts: n/a
 
      01-18-2005
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
 
Reply With Quote
 
 
 
 
Jakub
Guest
Posts: n/a
 
      01-18-2005
i thing simpliest way is to use DropDownList instead of select control
your code may be like this:

<asp:datagrid id="mygrid"
....
<ItemTemplate>
<aspropDownList 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBEYW4=?=
Guest
Posts: n/a
 
      01-18-2005
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>
> <aspropDownList 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Space between input boxes and selection boxes is not the same in Internet Explorer Stefan Mueller HTML 5 06-16-2009 02:06 PM
Datagrid problems using asp.net 1.1, sorting, displaying check boxes Scott ASP .Net 0 08-21-2007 12:56 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Sizing text entry boxes on in-place editing of datagrid row with dynamically created columns Keefe Goldfisher via .NET 247 ASP .Net Datagrid Control 0 03-07-2005 07:00 PM
DataGrid - Options for displaying many items in one row without requiring scrolling - HELP! James Radke ASP .Net Web Controls 3 10-13-2003 03:26 AM



Advertisments