473,324 Members | 2,473 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,324 software developers and data experts.

Gridview error

My Delete and select commands work like a charm, but Update won't
work!! Can someone help??

<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4"
DataSourceID="concept" ForeColor="#333333"
GridLines="None"
DataKeyNames="id,Description,unit,Quantity">
<FooterStyle BackColor="#990000" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="Quantity"
HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="unit"
HeaderText="unit" SortExpression="unit" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:CommandField ButtonType="Button"
ShowDeleteButton="True" />
<asp:BoundField DataField="id" HeaderText="id"
HtmlEncode="False" InsertVisible="False"
ReadOnly="True" ShowHeader="False"
SortExpression="id" />
<asp:CommandField ButtonType="Button"
ShowEditButton="True" />
</Columns>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333"
/>
<SelectedRowStyle BackColor="#FFCC66"
Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="concept" runat="server"
ConnectionString="<%$ ConnectionStrings:Concept608ConnectionString %>"
SelectCommand="SELECT Quantity, unit, Description,
id FROM reportMatList WHERE (boxNumber = @boxNumber) AND (quoteNumber =
@quoteNumber) AND (unitNumber = @unitNumber)"
DeleteCommand="DELETE FROM reportMatList WHERE
(boxNumber = @boxNumber) AND (quoteNumber = @quoteNumber) AND
(unitNumber = @unitNumber) AND (id = @id)"
UpdateCommand="UPDATE reportMatList SET Quantity =
@Quantity, unit = @unit, Description = @Description WHERE id = @id">
<SelectParameters>
<asp:QueryStringParameter Name="boxNumber"
QueryStringField="txtBoxNumber" Type="String" />
<asp:QueryStringParameter Name="quoteNumber"
QueryStringField="txtQuoteNumber" Type="String" />
<asp:QueryStringParameter Name="unitNumber"
QueryStringField="txtUnitNumber" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:QueryStringParameter Name="boxNumber"
QueryStringField="txtBoxNumber" Type="String" />
<asp:QueryStringParameter Name="quoteNumber"
QueryStringField="txtQuoteNumber" Type="String" />
<asp:QueryStringParameter Name="unitNumber"
QueryStringField="txtUnitNumber" Type="String" />
<asp:ControlParameter Name="id"
ControlID="Gridview1" Type=Int32 />
</DeleteParameters>
<UpdateParameters>
<asp:ControlParameter Name="Quantity"
ControlID="Gridview1" Type=Int32 />
<asp:ControlParameter Name="unit"
ControlID="Gridview1" Type=string />
<asp:ControlParameter Name="Description"
ControlID="Gridview1" Type=string />
<asp:ControlParameter Name="id"
ControlID="Gridview1" Type=Int32 />
</UpdateParameters>
</asp:SqlDataSource>

Apr 20 '06 #1
2 1175
You're using <asp:ControlParameter Name="id"
ControlID="Gridview1" Type=Int32 />. Basically, you tell your
SqlDataSource to search the GridView for a value, which is plain wrong
(you're not even specifying the PropertyName).

You should use something like <asp:Parameter Name="id" Type=Int32 />.
This way, the SqlDataSource will try to use the "id" field of the
edited row as the parameter's value.

Apr 21 '06 #2
Ok, thank! I will try this at the office today!

Apr 21 '06 #3

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

Similar topics

0
by: W. Kacy | last post by:
I am having trouble using XML in an ASP.NET 2.0 webform. Using ASP.NET 2.0 beta 2, I have created a blank web page in a C# website. I have added an XML file (soData.xml), structured as follows: ...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
1
by: James Rosewell | last post by:
I'm getting an error in the following scenario. - A GridView control is bound to an SQLDataSource. - The user selects a column for sorting. - Some time later in code the column used for sorting...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
3
by: =?Utf-8?B?bWFuaWthMDI=?= | last post by:
Hi, I have a GridView control in page called eventslisting which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type...
3
by: Dariusz Tomon | last post by:
Hello, I have GridView in EditItem Template of DetailsView (in normal - read-only mode there is a label). When I'm in edit mode I can select one item from GridView. The main problem is that as...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
0
by: Paul | last post by:
In GridView if I make the CommandArgument of a link button a string created from something like myGuid.ToString() the RowCommand handler dies with an error I can't track down. The only thing I know...
0
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
Hi, I have created a second gridview when customer clicks on select link with this code: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.