I have copied the following code from Internet, and copied it to a file
named : test.aspx, and copied that file to c:\Inetpub\wwwr oot Directory.
When I type on my Internet explorer: http:\\localhos t\test.aspx, following
error occured:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
A name was started with an invalid character. Error processing resource
'http://localhost/test.aspx'. Line 1, Position 2
<%@ Page Language="VB" %>
Any Idea what am I missing ?Best Regards,Luqman
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub DetailsView1_It emInserted(ByVa l sender As Object, ByVal e
As System.Web.UI.W ebControls.Deta ilsViewInserted EventArgs)
If (Not e.Exception Is Nothing) Then
ErrorMessageLab el.Text = "An error occured while entering this
record. Please verify you have entered data in the correct format."
e.ExceptionHand led = True
End If
GridView1.DataB ind()
End Sub
Protected Sub DetailsView1_It emUpdated(ByVal sender As Object, ByVal e
As System.Web.UI.W ebControls.Deta ilsViewUpdatedE ventArgs)
GridView1.DataB ind()
End Sub
Protected Sub DropDownList1_S electedIndexCha nged(ByVal sender As Object,
ByVal e As EventArgs)
DetailsView1.Ch angeMode(Detail sViewMode.ReadO nly)
End Sub
Protected Sub GridView1_Selec tedIndexChanged (ByVal sender As Object,
ByVal e As EventArgs)
DetailsView1.Ch angeMode(Detail sViewMode.ReadO nly)
End Sub
Protected Sub GridView1_PageI ndexChanged(ByV al sender As Object, ByVal e
As EventArgs)
DetailsView1.Ch angeMode(Detail sViewMode.ReadO nly)
End Sub
Protected Sub GridView1_Sorte d(ByVal sender As Object, ByVal e As
System.EventArg s)
DetailsView1.Ch angeMode(Detail sViewMode.ReadO nly)
End Sub
Protected Sub GridView1_RowDe leted(ByVal sender As Object, ByVal e As
GridViewDeleted EventArgs)
If (Not e.Exception Is Nothing) Then
ErrorMessageLab el.Text = "Failed to DELETE due to foreign key
contstraint on the table. You may only delete rows which have no related
records."
e.ExceptionHand led = True
End If
End Sub
Protected Sub DetailsView1_Da taBound(ByVal sender As Object, ByVal e As
EventArgs)
If (DetailsView1.C urrentMode = DetailsViewMode .Insert) Then
Dim stateTextBox As TextBox =
CType(DetailsVi ew1.Rows(6).Cel ls(1).Controls( 0), TextBox)
stateTextBox.Te xt = DropDownList1.S electedValue
stateTextBox.En abled = False
End If
End Sub
</script>
<html>
<head id="Head1" runat="server">
<title>GridVi ew DetailsView Master-Details (Insert)</title>
</head>
<body>
<form id="form1" runat="server">
<b>Choose a state:</b>
<asp:DropDownLi st ID="DropDownLis t1" DataSourceID="S qlDataSource2"
AutoPostBack="t rue"
DataTextField=" state" runat="server"
OnSelectedIndex Changed="DropDo wnList1_Selecte dIndexChanged" />
<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server"
SelectCommand=" SELECT DISTINCT [state] FROM [authors]"
ConnectionStrin g="<%$ ConnectionStrin gs:Pubs %>" />
<br />
<br />
<table>
<tr>
<td valign="top">
<asp:GridView ID="GridView1" AllowSorting="T rue"
AllowPaging="Tr ue" runat="server"
DataSourceID="S qlDataSource1" DataKeyNames="a u_id"
AutoGenerateCol umns="False" Width="500px" SelectedIndex=" 0"
OnSelectedIndex Changed="GridVi ew1_SelectedInd exChanged"
OnPageIndexChan ged="GridView1_ PageIndexChange d"
OnRowDeleted="G ridView1_RowDel eted" OnSorted="GridV iew1_Sorted">
<Columns>
<asp:CommandFie ld ShowSelectButto n="true"
ShowDeleteButto n="true" />
<asp:BoundFie ld DataField="au_i d" HeaderText="au_ id"
ReadOnly="True" SortExpression= "au_id" />
<asp:BoundFie ld DataField="au_l name" HeaderText="au_ lname"
SortExpression= "au_lname" />
<asp:BoundFie ld DataField="au_f name" HeaderText="au_ fname"
SortExpression= "au_fname" />
<asp:BoundFie ld DataField="stat e" HeaderText="sta te"
SortExpression= "state" />
</Columns>
</asp:GridView>
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:Pubs %>"
SelectCommand=" SELECT [au_id], [au_lname], [au_fname], [state]
FROM [authors] WHERE ([state] = @state)"
DeleteCommand=" DELETE FROM [authors] WHERE [au_id] = @au_id">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Drop DownList1" Name="state"
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>
</td>
<td valign="top">
<asp:DetailsVie w AutoGenerateRow s="False" DataKeyNames="a u_id"
DataSourceID="S qlDataSource3"
HeaderText="Aut hor Details" ID="DetailsView 1" runat="server"
Width="275px" OnItemUpdated=" DetailsView1_It emUpdated"
OnItemInserted= "DetailsView1_I temInserted"
OnDataBound="De tailsView1_Data Bound">
<Fields>
<asp:BoundFie ld DataField="au_i d" HeaderText="au_ id"
ReadOnly="True" SortExpression= "au_id" />
<asp:BoundFie ld DataField="au_l name" HeaderText="au_ lname"
SortExpression= "au_lname" />
<asp:BoundFie ld DataField="au_f name" HeaderText="au_ fname"
SortExpression= "au_fname" />
<asp:BoundFie ld DataField="phon e" HeaderText="pho ne"
SortExpression= "phone" />
<asp:BoundFie ld DataField="addr ess" HeaderText="add ress"
SortExpression= "address" />
<asp:BoundFie ld DataField="city " HeaderText="cit y"
SortExpression= "city" />
<asp:BoundFie ld DataField="stat e" HeaderText="sta te"
SortExpression= "state" />
<asp:BoundFie ld DataField="zip" HeaderText="zip "
SortExpression= "zip" />
<asp:CheckBoxFi eld DataField="cont ract" HeaderText="con tract"
SortExpression= "contract" />
<asp:CommandFie ld ShowEditButton= "True"
ShowInsertButto n="True" />
</Fields>
</asp:DetailsView >
<asp:SqlDataSou rce ID="SqlDataSour ce3" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:Pubs %>"
SelectCommand=" SELECT [au_id], [au_lname], [au_fname], [phone],
[address], [city], [state], [zip], [contract] FROM [authors] WHERE ([au_id]
= @au_id)"
UpdateCommand=" UPDATE [authors] SET [au_lname] = @au_lname,
[au_fname] = @au_fname, [phone] = @phone, [address] = @address, [city] =
@city, [state] = @state, [zip] = @zip, [contract] = @contract WHERE [au_id]
= @au_id"
InsertCommand=" INSERT INTO [authors] ([au_id], [au_lname],
[au_fname], [phone], [address], [city], [state], [zip], [contract]) VALUES
(@au_id, @au_lname, @au_fname, @phone, @address, @city, @state, @zip,
@contract)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Grid View1" Name="au_id"
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="au_lname" Type="String" />
<asp:Paramete r Name="au_fname" Type="String" />
<asp:Paramete r Name="phone" Type="String" />
<asp:Paramete r Name="address" Type="String" />
<asp:Paramete r Name="city" Type="String" />
<asp:Paramete r Name="state" Type="String" />
<asp:Paramete r Name="zip" Type="String" />
<asp:Paramete r Name="contract" Type="Boolean" />
<asp:Paramete r Name="au_id" Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="au_id" Type="String" />
<asp:Paramete r Name="au_lname" Type="String" />
<asp:Paramete r Name="au_fname" Type="String" />
<asp:Paramete r Name="phone" Type="String" />
<asp:Paramete r Name="address" Type="String" />
<asp:Paramete r Name="city" Type="String" />
<asp:Paramete r Name="state" Type="String" />
<asp:Paramete r Name="zip" Type="String" />
<asp:Paramete r Name="contract" Type="Boolean" />
</InsertParameter s>
</asp:SqlDataSour ce>
</td>
</tr>
</table>
<br />
<asp:Label ID="ErrorMessag eLabel" EnableViewState ="false" runat="server"
/>
</form>
</body>
</html>