Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Gridview Page not Updating?

Status
Not open for further replies.

Tr0

Programmer
Jul 12, 2007
24
US
I'm creating a simple gridview and when I submit the update the threshold value doesn't update in the database. Before I was recieving a scalar variable error, then I added the update parameters and now nothing happens when submitted.

Any suggestions???

Here's the code:


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-family: Tahoma">DOS UPDATE PAGE<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True"
CellPadding="4" DataSourceID="sqlDataSource" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="ulname" HeaderText="Last Name" ReadOnly="True" SortExpression="ulname" />
<asp:BoundField DataField="threshold" HeaderText="Minutes" SortExpression="threshold" />
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="sqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ecwSQLConnectionString %>"
SelectCommand="SELECT [ulname], [threshold] FROM [P_resource_params]" UpdateCommand="UPDATE [P_resource_params] SET [threshold]=@threshold WHERE [ulname]=@ulname">
<UpdateParameters>
<asp:parameter Name="ulname" />
<asp:parameter Name="threshold" />
</UpdateParameters>
</asp:SqlDataSource>
</span>

</div>
</form>
</body>
</html>
 
you you bind the grid after the update? this is required to the grid has the current data.

I would also discourage the use of DataSource controls. they are impossible to debug, and promote poor SOC. At a minimum use strongly typed datasets or a hand rolled DAL. I would recommend 3rd party ORM tools such as Active Record or NHibernate.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top