Newb ASP question

F

Fayven Wren

Can anyone assist a newb with troubleshooting the code below? I can
not seem to create new database records. I do not get any error
messages, just no new records. Editing and deleting works fine. I am
using VS 2005. If anyone can suggest a different, more active group
or web site I may be able to use in the future, I would appreciate it.

<%@ Page Language="VB" %>
<%@ import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub DetailsView1_ItemInserted(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
Response.Redirect("LOV.aspx")
End Sub

Protected Sub DetailsView1_ModeChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs)
If e.CancelingEdit = True Then
Response.Redirect("LOV.aspx")
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Details View Insert</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DetailsView DefaultMode="Insert" AutoGenerateRows="False"
DataKeyNames="Counter"
DataSourceID="SqlDataSource3" HeaderText="Insert LOV"
ID="DetailsView1" runat="server"
Width="275px" OnItemInserted="DetailsView1_ItemInserted"
OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="Counter" HeaderText="Counter"
ReadOnly="True" SortExpression="Counter" />
<asp:BoundField DataField="Code" HeaderText="Code"
SortExpression="Code" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Type" HeaderText="Type"
SortExpression="Type" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:pubsConnectionString %>"
SelectCommand="Select Counter, Code, Description, Type From
tlkpLOV Where Counter = @Counter"
InsertCommand="Insert Into tlkpLOV(Code, Description,
Dependant, Type) Values(@Code, @Description, 0, @Type)" >
<SelectParameters>
<asp:QueryStringParameter Name="Counter"
QueryStringField="Counter" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:parameter Name="Code" Type="String" />
<asp:parameter Name="Description" Type="String" />
<asp:parameter Name="Type" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top