•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 402,003 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,401 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5216 | Replies: 0
![]() |
•
•
Join Date: Jul 2004
Posts: 64
Reputation:
Rep Power: 5
Solved Threads: 0
Hi, i am trying to use new method in asp.net for the database connectivity. --> using gridview
yet i am facing problem here in the "adding new" area.
here goes my code:
The problem here is, i cant get my program to add new items.
but the other functions such as; edit, delete and view.... have no problem at all.
I would like to know what is the mistake(s) i have done in here. or am i doing the right thing?
Correct me if i am wrong.
Thank you
yet i am facing problem here in the "adding new" area.
here goes my code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="BillID">
<Columns>
<asp:CommandField ShowInsertButton="True" />
<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
<asp:TemplateField HeaderText="ItemNumber" SortExpression="ItemNumber">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ItemNumber") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ItemNumber") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" />
<asp:BoundField DataField="InvoiceDt" HeaderText="InvoiceDt" SortExpression="InvoiceDt" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="refNumber" HeaderText="refNumber" SortExpression="refNumber" />
<asp:BoundField DataField="ItemDt" HeaderText="ItemDt" SortExpression="ItemDt" />
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" readonly="True"/>
<asp:TemplateField></asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBClinicConnectionString2 %>"
SelectCommand="SELECT [BillID], [InvoiceDt], [Description], [ItemNumber], [ItemDt], [refNumber], [Company], [Amount], [UnitPrice], [Quantity] FROM [BillStatement]"
UpdateCommand = "Update [BillStatement]
SET
Company = @Company,
InvoiceDt = @InvoiceDt,
refNumber = @refNumber,
ItemNumber = @ItemNumber,
ItemDt = @ItemDt,
Description = @Description,
Quantity = @Quantity,
UnitPrice = UnitPrice
where BillID = @BillID "
DeleteCommand = "Delete [BillStatement] where BillID = @BillID "
InsertCommand= "INSERT INTO [BillStatement](Company,InvoiceDt,refNumber,ItemNumber,ItemDt,Description,Quantity,UnitPrice) VALUES (@Company,@InvoiceDt,@refNumber,@ItemNumber,@ItemDt,@Description,@Quantity,@UnitPrice)"
></asp:SqlDataSource>
</div>
</form>
</body>
</html>
The problem here is, i cant get my program to add new items.
but the other functions such as; edit, delete and view.... have no problem at all.
I would like to know what is the mistake(s) i have done in here. or am i doing the right thing?
Correct me if i am wrong.
Thank you
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Gridview Paging Problem. (C#)
- Asp.net-Database Insert problem (ASP.NET)
- CD ROM Trouble (Troubleshooting Dead Machines)
- Escape and Unescape / Handling (C)
- Access INSERT problem (MS Access and FileMaker Pro)
- Help! Drive not reading media. Arrg (Storage)
- A problem with a given Syntax! (Computer Science and Software Design)
Other Threads in the ASP.NET Forum
- Previous Thread: how can I create a forum ?
- Next Thread: update database through gridview


Linear Mode