472,328 Members | 1,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

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.

"Databinding 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

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...

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="GridViewDataSource"
AllowPaging="True" AllowSorting="True" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="15"
<asp:CommandField ShowEditButton="True" />
<asp:CommandField Visible="False"
ShowDeleteButton="True" DeleteText="Delete Vehicle" />
<asp:TemplateField HeaderText="Year"
<asp:DropDownList ID="DropDownList1"
runat="server" SelectedValue='<%# Bind("CD_ModelYear") %>'>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("CD_ModelYear") %>'></asp:Label>
<asp:TemplateField HeaderText="Make"
<asp:DropDownList ID="DDMakeEdit"
runat="server" AutoPostBack="True" DataSourceID="ManuDataSource"
DataValueField="MAN_ID" SelectedValue='<%# Eval("CD_ManID") %>'
OnDataBinding="Page_Load" OnDataBound="Page_Load">
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("MAN_Description") %>'></asp:Label>
<asp:TemplateField HeaderText="Model"
<asp:DropDownList ID="DDModelEdit"
runat="server" DataSourceID="ModelDataSource"
DataValueField="MOD_ID" SelectedValue='<%# "CD_ModID" %>'>
<asp:SqlDataSource ID="ModelDataSource"
runat="server" ConnectionString="<%$
ConnectionStrings:JTMConnectionString %>"
<asp:ControlParameter ControlID="DDMakeEdit"
Name="MAN_ID" PropertyName="SelectedValue"
Type="Int32" />
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("MOD_Description") %>'></asp:Label>
<asp:TemplateField HeaderText="Car Type"
<asp:DropDownList ID="DropDownList2"
runat="server" DataSourceID="CarTypeDataSource"
DataValueField="TYP_ID" SelectedValue='<%# Bind("TYP_ID") %>'>
ID="CarTypeDataSource" runat="server" ConnectionString="<%$
ConnectionStrings:JTMConnectionString %>"
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("TYP_Description") %>'></asp:Label>
<asp:TemplateField HeaderText="Engine"
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("ENG_Description") %>'></asp:Label>
<asp:TemplateField HeaderText="Transmission"
<asp:DropDownList ID="DDTransEdit"
runat="server" SelectedValue='<%# Bind("CD_TransType") %>'>
<asp:Label ID="Label6" runat="server" Text='<%#
Bind("CD_TransType") %>'></asp:Label>
<asp:TemplateField HeaderText="Date Sold"
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("CS_DateSold", "{0:d}") %>'></asp:TextBox>
<asp:Label ID="Label8" runat="server" Text='<%#
Bind("CS_DateSold", "{0:d}") %>'></asp:Label>
<asp:TemplateField HeaderText="Ending Bid"
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("CS_EndingPrice", "{0:C}") %>'></asp:TextBox>
<asp:Label ID="Label7" runat="server" Text='<%#
Bind("CS_EndingPrice", "{0:c}") %>'></asp:Label>
<asp:BoundField DataField="CS_TotalBids"
HeaderText="Total # of Bids" SortExpression="CS_TotalBids" />
<asp:BoundField DataField="CD_VIN" HeaderText="Vin #"
SortExpression="CD_VIN" />
<asp:CheckBoxField DataField="CS_ReserveMet"
HeaderText="Reserve Met" SortExpression="CS_ReserveMet" />
<asp:CheckBoxField DataField="CS_Sold"
HeaderText="Sold" SortExpression="CS_Sold" />
<asp:CheckBoxField DataField="CD_Clone" HeaderText="Is
a Clone?" SortExpression="CD_Clone" />
<asp:CheckBoxField DataField="CD_EngineMatch"
HeaderText="Engine Match" SortExpression="CD_EngineMatch" />
<asp:CheckBoxField DataField="CD_TransMatch"
HeaderText="Tran. Match" SortExpression="CD_TransMatch" />
<asp:CheckBoxField DataField="CD_CorrectEngSize"
HeaderText="Correct Eng. Size" SortExpression="CD_CorrectEngSize" />
<asp:CheckBoxField DataField="CD_EngineInc"
HeaderText="Engine Included" SortExpression="CD_EngineInc" />
<asp:CheckBoxField DataField="CD_TransInc"
HeaderText="Transmission Included" SortExpression="CD_TransInc" />
<asp:BoundField DataField="CD_PID" HeaderText="CD_PID"
InsertVisible="False" SortExpression="CD_PID"
Visible="False" />

<FooterStyle BackColor="#5D7B9D" BorderStyle="Solid"
Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" BorderStyle="Solid"
BorderWidth="1px" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
<asp:SqlDataSource ID="GridViewDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:JTMConnectionString %>"
SelectCommandType="StoredProcedure" DeleteCommand="sp_deletevehicle"
DeleteCommandType="StoredProcedure" >
<DeleteParameters><asp:Parameter name="CD_PID" Type="Int32"
<asp:SqlDataSource ID="ManuDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:JTMConnectionString %>"


Jan 5 '06 #1
6 6989
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-ObjectDataSource 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

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...
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...
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...
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...
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False"...
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...
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...
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...
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....
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.