ADD Feature to a Gridview

Discussion in 'ASP .Net' started by crocboy25, Sep 29, 2010.

  1. crocboy25

    crocboy25 Guest

    Hello Group,

    I am have been trying to include an "ADD" record feature to the top of
    a gridview with no luck as far. Does anyone have any method that they
    know of will work for this? I have googled for days without finding
    anything that has been effective as of yet.

    Any help would be greatly appreciated.

    Thanks
     
    crocboy25, Sep 29, 2010
    #1
    1. Advertisements

  2. crocboy25

    joharishr

    Joined:
    Oct 1, 2010
    Messages:
    1
    Likes Received:
    0
    Add a linkbutton

    <asp:LinkButton ID="lblNew" runat="server" CausesValidation="false"
    CommandName="Insert"
    Text="Click here to add new" style="vertical-align: middle; text-align:
    center" Font-Bold="False" ForeColor="Black"
    OnClick="GridViewInsert">
    </asp:LinkButton>

    In the .cs page add:

    protected void GridViewInsert(object sender, EventArgs e)
    {
    SqlDataSource1.Insert();
    }

    How the above works:
    Adds an extra row in the gridview. on click of the above linkbutton, the function GridViewInsert is called which simply inserts a row in the Gridview.
    Note: An empty row will be inserted. To add data in the row you need to add the Edit, Update CommandFeild. We're just working around a solution since there's no Add functionality in a Gridview the way it has Edit, Update.
     
    joharishr, Oct 1, 2010
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.