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
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"
AutoGenerateColumns="False" DataSourceID="GridViewDataSource"
AllowPaging="True" AllowSorting="True" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="15"
DataKeyNames="CD_PID">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField Visible="False"
ShowDeleteButton="True" DeleteText="Delete Vehicle" />
<asp:TemplateField HeaderText="Year"
SortExpression="CD_ModelYear">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1"
runat="server" SelectedValue='<%# Bind("CD_ModelYear") %>'>
<asp:ListItem>1969</asp:ListItem>
<asp:ListItem>1970</asp:ListItem>
<asp:ListItem>1971</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("CD_ModelYear") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Make"
SortExpression="MAN_Description">
<EditItemTemplate>
<asp:DropDownList ID="DDMakeEdit"
runat="server" AutoPostBack="True" DataSourceID="ManuDataSource"
DataTextField="MAN_Description"
DataValueField="MAN_ID" SelectedValue='<%# Eval("CD_ManID") %>'
OnDataBinding="Page_Load" OnDataBound="Page_Load">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("MAN_Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Model"
SortExpression="MOD_Description">
<EditItemTemplate>
<asp:DropDownList ID="DDModelEdit"
runat="server" DataSourceID="ModelDataSource"
DataTextField="MOD_Description"
DataValueField="MOD_ID" SelectedValue='<%# "CD_ModID" %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="ModelDataSource"
runat="server" ConnectionString="<%$
ConnectionStrings:JTMConnectionString %>"
SelectCommand="sp_getmodels"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="DDMakeEdit"
Name="MAN_ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("MOD_Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Car Type"
SortExpression="TYP_Description">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2"
runat="server" DataSourceID="CarTypeDataSource"
DataTextField="TYP_Description"
DataValueField="TYP_ID" SelectedValue='<%# Bind("TYP_ID") %>'>
</asp:DropDownList><asp:SqlDataSource
ID="CarTypeDataSource" runat="server" ConnectionString="<%$
ConnectionStrings:JTMConnectionString %>"
SelectCommand="sp_gettypes"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("TYP_Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Engine"
SortExpression="ENG_Description">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("ENG_Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Transmission"
SortExpression="CD_TransType">
<EditItemTemplate>
<asp:DropDownList ID="DDTransEdit"
runat="server" SelectedValue='<%# Bind("CD_TransType") %>'>
<asp:ListItem>Automatic</asp:ListItem>
<asp:ListItem>Manual</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%#
Bind("CD_TransType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Sold"
SortExpression="CS_DateSold">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("CS_DateSold", "{0:d}") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%#
Bind("CS_DateSold", "{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Ending Bid"
SortExpression="CS_EndingPrice">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("CS_EndingPrice", "{0:C}") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%#
Bind("CS_EndingPrice", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<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" />

</Columns>
<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:GridView>
&nbsp;</div>
<asp:SqlDataSource ID="GridViewDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:JTMConnectionString %>"
SelectCommand="sp_GetCarDetails"
SelectCommandType="StoredProcedure" DeleteCommand="sp_deletevehicle"
DeleteCommandType="StoredProcedure" >
<DeleteParameters><asp:Parameter name="CD_PID" Type="Int32"
/></DeleteParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="ManuDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:JTMConnectionString %>"
SelectCommand="sp_getmanu"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>

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

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

1
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...
3
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...
4
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...
1
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...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False"...
0
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...
0
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...
3
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...
11
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....
0
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...
0
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...
0
better678
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...
0
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...
0
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...
0
jalbright99669
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
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. ...
0
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.