Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 11th, 2005, 09:36 AM
Registered User
 
Join Date: Mar 2005
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid error with inline dropdown list

Hi,

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();
        SqlDa.Fill(ds);

        return ds;
    }
.
.
.


.
.
.

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

<asp:BoundColumn DataField="IncidentID" HeaderText="ID" />
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList
AutoPostBack="true"
DataSource="<%# GetTypes() %>"
HeaderText="ID"
DataValueField="TypeID"
DataTextField="TypeDesc"
SelectedIndex='<%# GetSelIndex(Container.DataItem("TypeID")) %>'
ID="ItemDropDown"
OnSelectedIndexChanged="Update_Type_ID"
Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

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


Many Thanks


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.