Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 11th, 2005, 09:36 AM
Registered User
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid error with inline dropdown list


This is my first post to the Wrox forums, and I was hoping that somebody could help with a problem.

I have a DropDownList that is within a Datagrid. The list is populated from a database table, and I would like to set the selectedindex according to the value stored for each row.

The idea is that it will be possible to change the value on each row using the dropdown of valid values.

However, I am getting the error
'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected

The problem is being caused by the line:

SelectedIndex='<%# GetSelIndex(Container.DataItem("TypeID")) %>'

Here is my code...
     DataSet GetTypes()
        SqlConnection SqlCon = new SqlConnection(ConnectionString);
        SqlDataAdapter SqlDa = new SqlDataAdapter("SELECT * FROM IncidentType", SqlCon);

        DataSet ds = new DataSet();

        return ds;


<asp:DataGrid AutoGenerateColumns="false" ID="incident" runat="server">

<asp:BoundColumn DataField="IncidentID" HeaderText="ID" />
DataSource="<%# GetTypes() %>"
SelectedIndex='<%# GetSelIndex(Container.DataItem("TypeID")) %>'
Runat="server" />

<asp:BoundColumn DataField="SummaryDesc" HeaderText="Summary" />

Many Thanks

Similar Threads
Thread Thread Starter Forum Replies Last Post
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
Dropdown list in a datagrid maddy137 ASP.NET 1.0 and 1.1 Professional 0 May 19th, 2006 02:05 PM
populating a dropdown list within a datagrid in C# akshay144 General .NET 0 May 12th, 2006 04:44 AM
problem with dropdown list in datagrid marty_nguyen Classic ASP Databases 1 May 22nd, 2005 06:16 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.