Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2006, 07:59 AM
Authorized User
 
Join Date: Mar 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default Problem with: Add new record in GridView

Hello,
First of all that might be kind of a stupid question but I really need it:). Here it is-->I have tried to insert new record in gridview but when I click on the "NEW" - link button, I just do nothing. So i've looked all arround and didn't find something that can help me. All the help code is using Code Behind and bind() the gridView. Actually I would like to make it as least code behind as I can. Any advice? Here is the "source":

Code:
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProdID"
        DataMember="DefaultView" DataSourceID="AccessDataSource1" HorizontalAlign="Center" AllowPaging="True" AllowSorting="True" TabIndex="3" BackColor="Transparent" Caption="#1063;#1072;#1089;#1090;#1080; - #1055;#1088;#1086;#1076;#1091;#1082;#1090;#1080;" OnRowUpdated="GridView2_RowUpdated" OnRowDeleted="GridView2_RowDeleted">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True"
                ShowInsertButton="True" />
            <asp:BoundField DataField="ImeProd" HeaderText="ImeProd" SortExpression="ImeProd" />
            <asp:BoundField DataField="Cena" HeaderText="Cena" SortExpression="Cena" />
            <asp:ImageField DataAlternateTextField="SnimkaProd" dataimageurlformatstring="/website3/images/Products/{0}.jpg" DataAlternateTextFormatString="snimka na: {0}"
                DataImageUrlField="SnimkaProd" HeaderText="Image" NullDisplayText="Empty">
            </asp:ImageField>
            <asp:TemplateField HeaderText="Upload File" ShowHeader="False" Visible="False">
    <EditItemTemplate>
        <input id="MyFile" type="file" runat="server" />
    </EditItemTemplate>

</asp:TemplateField>
        </Columns>
    </asp:GridView>

and this is the AccessDAtaSource:

Code:
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Li4niDanni.mdb"
        SelectCommand="SELECT SnimkaProd, ProdID, ImeProd, Cena, CategorID FROM Produkti WHERE ([CategorID] = @CatIDSelected)"
        UpdateCommand="UPDATE [Produkti] SET [SnimkaProd] = @SnimkaProd, [ImeProd] = @ImeProd, [Cena] = @Cena WHERE ProdID=@ProdID"
        InsertCommand="INSERT INTO [Produkti] (ProdID, ImeProd, Cena, SnimkaProd) VALUES (@ProdID, @ImeProd, @Cena, @SnimkaProd)"
        DeleteCommand="DELETE FROM [Produkti] WHERE [ProdID] = @ProdID">
        <SelectParameters>
        <asp:ControlParameter ControlID="GridView3" Name="CatIDSelected" PropertyName="SelectedValue"/>
        </SelectParameters>
        <DeleteParameters>
           <asp:Parameter Name="ProdID" Type="String" />
        </DeleteParameters>
        <InsertParameters>
              <asp:Parameter Name="SnimkaProd" Type="String" />
              <asp:Parameter Name="Cena" Type="String" />
              <asp:Parameter Name="ImeProd" Type="String" />
              <asp:Parameter Name="ProdID" Type="String" />
        </InsertParameters>
        <UpdateParameters>
              <asp:Parameter Name="SnimkaProd" Type="String" />
              <asp:Parameter Name="ImeProd" Type="String" />
              <asp:Parameter Name="Cena" Type="String" />
              <asp:Parameter Name="ProdID" Type="String" />
        </UpdateParameters>
        </asp:AccessDataSource>
Thanks You,
G. Kalchev





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting and record Selection problem in GridView Dmitriy ASP.NET 3.5 Professionals 0 September 24th, 2008 03:18 PM
How to add a new column into gridview? Bryan Stanley ASP.NET 2.0 Basics 0 September 12th, 2007 10:49 PM
record add problem newbie here jdsflash ASP.NET 1.0 and 1.1 Basics 3 May 19th, 2006 12:04 PM
how to add new record as first record in dataset hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
Select gridview record with mouseclick wirerider ASP.NET 2.0 Basics 2 March 9th, 2006 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.