Hey. I'm pretty new to ASP.NET and coding it in VB. I'm working on some tutorials on how to view and edit data from a SQL Data Source. I'm using the GridView feature, but I'm getting some errors. The major one, is that it requires me to declare a scalar variable, while the code in the book has none, and after trying to fix it, I'm getting to new errors while compiling, so the web page wont even load. I've been searching for a fix, but I don't understand what I've been finding. I'm including the code I have, and the two compiling errors I'm getting. Thanks for the help.
-Jesse
<%@ Page Debug="true" Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebMatrix.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub On_Click(ByVal source As Object, ByVal e As EventArgs)
SqlDataSource1.Update()
End Sub 'On_Click
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display.">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="lName" HeaderText="lName"
SortExpression="lName" />
<asp:BoundField DataField="fName" HeaderText="fName"
SortExpression="fName" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="Zip Code" HeaderText="Zip Code"
SortExpression="Zip Code" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT ID, lName, fName, City, State, [Zip Code] FROM InfoTester"
UpdateCommand="UPDATE InfoTester SET fName = @fName WHERE lName = 'Jobs'">
<UpdateParameters>
<asp:ControlParameter Name="LastName" ControlID="DropDownList1" PropertyName="SelectedValue" />
<asp:ControlParameter Name="fName" ControlID="GridView1" PropertyName="SelectedValue" />
</UpdateParameters>
</asp:SqlDataSource>
<p>
<asp:DropDownList id="DropDownList1" runat="server" DataTextField="lName" DataValueField="lName" DataSourceID="SqlDataSource1"></asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Enter the new First Name" AssociatedControlID = "TextBox1" />
<asp:TextBox
ID="TextBox1" runat="server" style="margin-left: 17px" Width="110px"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
style="margin-left: 17px; margin-bottom: 0px" Text="Enter"
OnClick="On_Click" Width="45px" />
</p>
<p>
Type the new First Name of the person below. Click enter to see if I know what
I'm doing.</p>
<asp:TextBox ID="TextBox2" runat="server" Width="198px"></asp:TextBox>
</form>
</body>
</html>
Here's the compiling errors:
Error 1 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. F:\WebMatrix\03B_fanbiopretty\web.config 86
Warning 2 F:\WebMatrix\WebMatrix\WebMatrix\Default.aspx: ASP.NET runtime error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (F:\WebMatrix\webmatrix\webmatrix\web.config line 84) F:\WebMatrix\WebMatrix\WebMatrix\Default.aspx 1 1 F:\WebMatrix\