469,923 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

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 6901
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John A Grandy | last post: by
4 posts views Thread by | last post: by
1 post views Thread by rituchandra0972 | last post: by
1 post views Thread by Evan M. | last post: by
3 posts views Thread by =?Utf-8?B?V2FubmFiZQ==?= | last post: by
11 posts views Thread by SAL | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.