473,326 Members | 2,113 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,326 software developers and data experts.

Need Help With Datagrid Template Column and Drop Down List Box

I am a .NET newbie, and need some help.

I have a datagrid that is bound to a table. That works. I also have a
template column in the grid for updating a status value for each row. This
is defined as:

<asp:TemplateColumn HeaderText="New Order Status">
<ItemTemplate>
<asp:DropDownList Font-Names="Arial" Font-Size="XX-Small"
id="drpOrderStatus"
runat="server" AutoPostBack="true"
OnSelectedIndexChanged="drpOrderStatus_SelectedInd exChanged"
Width="165">
<asp:ListItem Value="0">New</asp:ListItem>
<asp:ListItem Value="1000">Loan Approved</asp:ListItem>
<asp:ListItem Value="1001">Loan Approved With
Gurantee</asp:ListItem>
<asp:ListItem Value="1002">Loan Declined</asp:ListItem>
<asp:ListItem Value="1003">Loan Requires More
Information</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>

In the click event of a button, Save button, I want to loop through my grid
and check the value of each drop box. I have not been able to get this to
work. In this event, I can put a watch on:

dgrdResults.items(i).cells(0).controls(1)

And I can see the drop down list box, but:

dgrdResults.items(i).cells(0).controls(1).Selected Value

doesn't work. Any thoughts?

BV.

Nov 18 '05 #1
2 1627
Hi Benign,

You need to convert the control to a dropdownlist. Try something like
the following.

DropDownList ddl =
(DropDownList)dgrdResults.items(i).cells(0).contro ls(1)
string myValue = ddl.SelectedValue
Hope this helps.

Tod Birdsall, MCP
http://tod1d.blogspot.com

Nov 18 '05 #2

"Tod Birdsall" <no*****@netsalad.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi Benign,

You need to convert the control to a dropdownlist. Try something like
the following.

DropDownList ddl =
(DropDownList)dgrdResults.items(i).cells(0).contro ls(1)
string myValue = ddl.SelectedValue
Hope this helps.

Tod Birdsall, MCP
http://tod1d.blogspot.com


Tod! Thanks! That was EXACTLY what I needed. Would you be able to point me
to some documentation that exlains the reason and purpose behind this? I'd
like to know what I just did.

BV.
Nov 18 '05 #3

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

Similar topics

2
by: bob | last post by:
I thought I saw this somewhere, but I want to have a dropdownlist in a datagrid. I have the column as an Item template, but when I paste in the code for a dropdown list funky things seem to...
3
by: Mike | last post by:
I have a web page that displays contact people in a drop down. the users selects a person then clicks the go button. The datagrid should pop with all the information on the select contact person,...
2
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After...
2
by: alien2_51 | last post by:
In the EditCommand event I've added a drop down list to the controls collection for the cell I want to edit. Dim objDDLBrake As New DropDownList objDDLBrake.CssClass = "label1" ...
1
by: Chris | last post by:
I have a datagrid with 3 columns Name quantity status This grid is populated from a sqldatareader. grid.datasource = datareader grid.databind() I now want to set the quantity column to a...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
2
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I am new in asp.net, i encounter some problems in using drop down list and datagrid. I have manage to bind the data into datagrid but i wanted to bind the data into the datagrid accroding...
1
by: Ken Varn | last post by:
I have a problem where my DataGrid would not maintain the ViewState of my databound rows. I finally narrowed down the problem. If my first column is a template column, the view state for the...
1
by: Joe Spears | last post by:
Hi I want to display a datagrid summary of a datatable. The grid will not show all the fields, but when the user selects a row, I want the other controls (text boxes) to also bind to the same row...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.