473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

beta 2 gridview edit problem

I am trying to create a simple editable gridview and I can't get my code
to work :

<asp:GridView ID="GridView1" Width=500px
DataSourceID="SqlDataSource1"
CellPadding="3"
Font-Names="arial"
Font-Size="8pt"
HeaderStyle-BackColor="#dcdcdc"
HeaderStyle-Font-Bold="true"
HeaderStyle-ForeColor="#00015E"
FooterStyle-BackColor="#CCCCCC"
SelectedRowStyle-BackColor="#FFFFFF"
PagerStyle-BackColor=Gray
PagerSettings-Mode=NumericFirstLast
BackColor="#0066CC"
Forecolor="white"
PageSize="10"
AllowPaging=true
AllowSorting=true
AutoGenerateColumns=false
DataKeyNames="CompanyID"
EditRowStyle-BackColor=Gold
EditRowStyle-Font-Names="Arial"
EditRowStyle-ForeColor=Black
Runat="server">
<Columns>
<asp:BoundField Visible=false DataField="CompanyID"
ReadOnly=true />
<asp:BoundField HeaderText="Company Name"
DataField="CompanyName" SortExpression="CompanyName" />
<asp:BoundField HeaderText="Location"
DataField="CompanyLocation" SortExpression="CompanyLocation" />
<asp:CheckBoxField HeaderText="Delivery"
DataField="Delivery" SortExpression="Delivery" />
<asp:BoundField HeaderText="Established"
DataField="DateEstablished" SortExpression="DateEstablished" />
<asp:BoundField HeaderImageUrl="~/Images/globe.jpg"
DataField="Country" SortExpression="Country" NullDisplayText="N/A" />
<asp:CommandField ShowEditButton=true ButtonType=Button
/>
<asp:CommandField ShowDeleteButton=true
ButtonType=Button />
</Columns>
</asp:GridView><BR />

<asp:DetailsView ID="DetailsView1"
DataSourceID="SqlDataSource1"
AllowPaging=true
Runat="server">
</asp:DetailsView>

<asp:SqlDataSource ID="SqlDataSource1" runat=server
SelectCommand="SELECT * FROM COMPANY"
ProviderName="<%$ ConnectionStrings:ourco.providerName %>"
ConnectionString="<%$ ConnectionStrings:ourco%>"
UpdateCommand="UPDATE Company SET CompanyName = @CompanyName,
CompanyLocation = @CompanyLocation,
Delivery = @Delivery, DateEstablished =
@DateEstablished, Country = @Country
WHERE CompanyID = @CompanyID"
DeleteCommand="DELETE FROM Company WHERE CompanyID =
@CompanyID">
<UpdateParameters>
<asp:Parameter Name="CompanyID" Type=Int32 />
<asp:Parameter Name="CompanyName" Type=String />
<asp:Parameter Name="CompanyLocation" Type=String />
<asp:Parameter Name="Delivery" Type=Boolean />
<asp:Parameter Name="DateEstablished" Type=DateTime />
<asp:Parameter Name="Country" Type=String />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="CompanyID" Type=Int32 />
</DeleteParameters>
</asp:SqlDataSource>

When I try to do an edit on a row I get the error :

Must declare the scalar variable "@CompanyID"

And when I try to delete a row, I don't get an error but nothing
happens. Does anybody have any ideas what I am doing wrong?
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
0 1007

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

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
1
by: Andrew Nav | last post by:
I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a...
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 presses Start button then I create...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
1
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"...
6
by: McGeeky | last post by:
Hi. GridView's inbuilt capability to edit/update individual rows, one at a time, is useful but inadequate for a scenario we currently face. I want the user to be able to change values in multiple...
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 with a value in the grid row to pass to the...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
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. The datatable is based on a join so I don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.