473,700 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.net 2.0 GridView edit mode problems

I have a Grid that I've set up to have two of the fields use
dropdownlists while in edit mode. Now I can bind the data to the
dropdownlists just fine. My problem is that the second dropdown depends
on the first dropdown to pass a parameter to it. If I have a
selectedvalue set to the second drop down, when i select a new value
from the first drop down it gives me this error.

"Databindin g methods such as Eval(), XPath(), and Bind() can only be
used in the context of a databound control."

After searching around for nearly a whole day, I have tried a million
things, including something like what was done here
http://www.webswapp.com/CodeSamples/...FormView1.aspx

summary: The first dropdown has autopostback set to true, on
autopostback it feeds a parameter to the second dropdown to update it's
list. If the second dropdown has a SelectedValue set, then it returns
the error. If it is not set (which leaves way too much room for user
error since it will auto default to the top of the list) it works fine.
I need this to work, and it seems with as easy as everything else is
with the gridview that this is something relatively silly to get stuck
on. Thanks in advance for everyone's help. The code is below...

----------------------------------------CODE------------------------------------------------------
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataSourceID="G ridViewDataSour ce"
AllowPaging="Tr ue" AllowSorting="T rue" CellPadding="4"
ForeColor="#333 333" GridLines="None " PageSize="15"
DataKeyNames="C D_PID">
<Columns>
<asp:CommandFie ld ShowEditButton= "True" />
<asp:CommandFie ld Visible="False"
ShowDeleteButto n="True" DeleteText="Del ete Vehicle" />
<asp:TemplateFi eld HeaderText="Yea r"
SortExpression= "CD_ModelYe ar">
<EditItemTempla te>
<asp:DropDownLi st ID="DropDownLis t1"
runat="server" SelectedValue=' <%# Bind("CD_ModelY ear") %>'>
<asp:ListItem>1 969</asp:ListItem>
<asp:ListItem>1 970</asp:ListItem>
<asp:ListItem>1 971</asp:ListItem>
</asp:DropDownLis t>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("CD_ModelY ear") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Mak e"
SortExpression= "MAN_Descriptio n">
<EditItemTempla te>
<asp:DropDownLi st ID="DDMakeEdit "
runat="server" AutoPostBack="T rue" DataSourceID="M anuDataSource"
DataTextField=" MAN_Description "
DataValueField= "MAN_ID" SelectedValue=' <%# Eval("CD_ManID" ) %>'
OnDataBinding=" Page_Load" OnDataBound="Pa ge_Load">
</asp:DropDownLis t>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("MAN_Descr iption") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Mod el"
SortExpression= "MOD_Descriptio n">
<EditItemTempla te>
<asp:DropDownLi st ID="DDModelEdit "
runat="server" DataSourceID="M odelDataSource"
DataTextField=" MOD_Description "
DataValueField= "MOD_ID" SelectedValue=' <%# "CD_ModID" %>'>
</asp:DropDownLis t>
<asp:SqlDataSou rce ID="ModelDataSo urce"
runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:JTMConnectio nString %>"
SelectCommand=" sp_getmodels"
SelectCommandTy pe="StoredProce dure">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="DDMa keEdit"
Name="MAN_ID" PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("MOD_Descr iption") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Car Type"
SortExpression= "TYP_Descriptio n">
<EditItemTempla te>
<asp:DropDownLi st ID="DropDownLis t2"
runat="server" DataSourceID="C arTypeDataSourc e"
DataTextField=" TYP_Description "
DataValueField= "TYP_ID" SelectedValue=' <%# Bind("TYP_ID") %>'>
</asp:DropDownLis t><asp:SqlDataS ource
ID="CarTypeData Source" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:JTMConnectio nString %>"
SelectCommand=" sp_gettypes"
SelectCommandTy pe="StoredProce dure"></asp:SqlDataSour ce>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("TYP_Descr iption") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Eng ine"
SortExpression= "ENG_Descriptio n">
<ItemTemplate >
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("ENG_Descr iption") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Tra nsmission"
SortExpression= "CD_TransTy pe">
<EditItemTempla te>
<asp:DropDownLi st ID="DDTransEdit "
runat="server" SelectedValue=' <%# Bind("CD_TransT ype") %>'>
<asp:ListItem>A utomatic</asp:ListItem>
<asp:ListItem>M anual</asp:ListItem>
</asp:DropDownLis t>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label6" runat="server" Text='<%#
Bind("CD_TransT ype") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Dat e Sold"
SortExpression= "CS_DateSol d">
<EditItemTempla te>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("CS_DateSo ld", "{0:d}") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label8" runat="server" Text='<%#
Bind("CS_DateSo ld", "{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="End ing Bid"
SortExpression= "CS_EndingPrice ">
<EditItemTempla te>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("CS_Ending Price", "{0:C}") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label7" runat="server" Text='<%#
Bind("CS_Ending Price", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:BoundFie ld DataField="CS_T otalBids"
HeaderText="Tot al # of Bids" SortExpression= "CS_TotalBi ds" />
<asp:BoundFie ld DataField="CD_V IN" HeaderText="Vin #"
SortExpression= "CD_VIN" />
<asp:CheckBoxFi eld DataField="CS_R eserveMet"
HeaderText="Res erve Met" SortExpression= "CS_Reserve Met" />
<asp:CheckBoxFi eld DataField="CS_S old"
HeaderText="Sol d" SortExpression= "CS_Sold" />
<asp:CheckBoxFi eld DataField="CD_C lone" HeaderText="Is
a Clone?" SortExpression= "CD_Clone" />
<asp:CheckBoxFi eld DataField="CD_E ngineMatch"
HeaderText="Eng ine Match" SortExpression= "CD_EngineMatch " />
<asp:CheckBoxFi eld DataField="CD_T ransMatch"
HeaderText="Tra n. Match" SortExpression= "CD_TransMa tch" />
<asp:CheckBoxFi eld DataField="CD_C orrectEngSize"
HeaderText="Cor rect Eng. Size" SortExpression= "CD_CorrectEngS ize" />
<asp:CheckBoxFi eld DataField="CD_E ngineInc"
HeaderText="Eng ine Included" SortExpression= "CD_EngineI nc" />
<asp:CheckBoxFi eld DataField="CD_T ransInc"
HeaderText="Tra nsmission Included" SortExpression= "CD_TransIn c" />
<asp:BoundFie ld DataField="CD_P ID" HeaderText="CD_ PID"
InsertVisible=" False" SortExpression= "CD_PID"
Visible="False" />

</Columns>
<FooterStyle BackColor="#5D7 B9D" BorderStyle="So lid"
Font-Bold="True" ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" BorderStyle="So lid"
BorderWidth="1p x" ForeColor="#333 333" />
<EditRowStyle BackColor="#999 999" />
<SelectedRowSty le BackColor="#E2D ED6" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775"
/>
</asp:GridView>
&nbsp;</div>
<asp:SqlDataSou rce ID="GridViewDat aSource" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:JTMConnectio nString %>"
SelectCommand=" sp_GetCarDetail s"
SelectCommandTy pe="StoredProce dure" DeleteCommand=" sp_deletevehicl e"
DeleteCommandTy pe="StoredProce dure" >
<DeleteParamete rs><asp:Paramet er name="CD_PID" Type="Int32"
/></DeleteParameter s>
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="ManuDataSou rce" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:JTMConnectio nString %>"
SelectCommand=" sp_getmanu"
SelectCommandTy pe="StoredProce dure"></asp:SqlDataSour ce>

----------------------------------------CODE------------------------------------------------------

Jan 5 '06 #1
6 7071
well dang, maybe i posted this too late in the day :|

Jan 6 '06 #2
so NOBODY has had this issue before?

Jan 6 '06 #3
wow i'm surprised, this must be a real problem because i normally get a
reply to my queries in like an hour here!

Jan 6 '06 #4
so NOBODY else has had this problem?

Jan 7 '06 #5
Gridview-ObjectDataSourc e are even worse...
Yes - I have problems as well - not the kind you have.
I am not able to retrive values from my grid at all !!
Very usefull ! Just to inform you in searching for help.

regards cgsh
"tfsmag" wrote:
so NOBODY else has had this problem?

Jan 8 '06 #6
bump for monday morning :P

Jan 9 '06 #7

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

Similar topics

1
1768
by: John A Grandy | last post by:
I'm not using SqlDataSource or ObjectDataSource. I'm handling events , similar to approach commonly used in 1.1. DataGrid. My question is : How do I configure a GridView's edit mode row format ? Here is my aspx : <asp:GridView ID="gvTasks" runat="server" AllowSorting="true" BackColor="Aqua"
3
19262
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create programatically a dataSet, set it as a DataSource for my GridView an add it to Session. 3. I want my users to be able to edit data displayed in GridView, so I added Edit command column. 4. When user clicks Edit, then I get the following error: "The GridView
4
2066
by: | last post by:
I wanted better control over the display of the command buttons, so I created Template columns for each command. (Otherwise the GridView was putting extras spacing around the images and such.) Is there a way to tell the GridView to only show certain columns if that particular row is in edit mode? I can hide the Edit and Delete buttons when entering edit mode, but when I display save and cancel buttons by enabling their rowns, not...
1
1454
by: rituchandra0972 | last post by:
Hello, I am new to ASP 2.0 and have been trying to work with the new gridview. I am running into road blocks as I try to implement quite a simple functionality. My functionality is as follows 1. There is a grid that manipulates data through two webservices. This grid has one field that is displayed as a dropdown in Edit mode. The dropdown box has only two values that can be hardcoded (as opposed to populating it from the database)....
1
10404
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID" OnRowCreated="ContactHistoryGrid_RowCreated" CssClass="GridViewTable" GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True" AllowPaging="True"> <EmptyDataTemplate>
0
4819
by: mike0870 | last post by:
Hi, I've been at this one for hours and cannot not find any posts of anyone having the same problem. Ther scenario is, I need to fill a drop down box with a value in the grid row to pass to the select statement whcih returns the rows to the drop down. Its the problem is happening in the ObjectDataSource_Selecting Event of the dropdown control when the Edit command is clicked for a grid row. I'm using the syntax , GridView.rows.FindControl...
0
1886
by: Fabrizio | last post by:
Hi all. I have a field in a gridview as templatefield which is a label in view mode and a dropdownlist in edit mode with his datasource. This gridview is inserted as templatefield in another mother gridview. GRIDVIEW1 - GRIDVIEW2
3
2182
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that uses a sqldatasource. The rows of the gridview are editable. When the gridview is in edit mode, one of the columns is a dropdown. In testing the editing, I deleted the dropdown entry from one of the rows. So, when the gridview comes up, it shows nothing in the column where I deleted it. Then when I select to edit that same row, I get an error because I cannot select the value for the dropdown for a non-existing value....
11
6062
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know if that's what's causing the behavior or not. It seems like the Update button should at least do something. When the Edit button is clicked, the grid goes into Edit mode and the Cancel button takes the grid out of Edit mode. So, I don't get what...
0
8716
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
8641
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
9060
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
7799
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4397
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...
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2380
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2021
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.