| | |
GridView Insert Problem
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2004
Posts: 65
Reputation:
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
![]() |
Similar Threads
- 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)
Other Threads in the ASP.NET Forum
- Previous Thread: Grid and Data not showing up when viewing in browser
- Next Thread: JW player - white box problem, movie not loaded
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dropdownlist dropdownmenu dynamic edit embeddingactivexcontrol expose findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list login menu microsoft mono mssql multistepregistration nameisnotdeclared numerical objects order panelmasterpagebuttoncontrols problem ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql sqlserver2005 ssl suse textbox tracking unauthorized validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment webservice wizard xml youareanotmemberofthedebuggerusers





