Newbie, add a button to gridview footer

Discussion in 'ASP .Net Datagrid Control' started by verci, Sep 3, 2006.

  1. verci

    verci Guest

    Hi
    Can anyone help me or point me in the right direction, I'm running Win XP
    Pro SP2, VS2005 Team, .Net Framework
    2.0 and SQL Server2005.

    I want to put a command button in the footer just below the links for edit
    and delete autogenerated by the gridview, this because I want to open
    another aspx page when the this button is pressed, my control code is below.

    Best Regards


    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    Inherits="Default3" %>

    <!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:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
    ConnectionStrings:NwindConnectionString %>"

    SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    c.CategoryID"

    UpdateCommand="Update Products Set ProductID=@ProductID,
    ProductName=@ProductName, CategoryID=@CategoryID where ProductID=@ProductID"

    deletecommand="delete from products where productid=@productid">

    <DeleteParameters>

    <asp:parameter Name="productID" Type="Int32" />

    </DeleteParameters>

    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
    ConnectionStrings:NwindConnectionString %>"

    SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">

    </asp:SqlDataSource>

    </div>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    GridLines="None" AllowPaging="True" DataKeyNames="productID" >

    <Columns>

    <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    EditImageUrl="~/Images/WRITE2.gif"

    ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />

    <asp:TemplateField SortExpression="ProductID">

    <EditItemTemplate>

    <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    Visible=false></asp:Label>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    Visible=false></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    SortExpression="ProductName" />

    <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">

    <EditItemTemplate>

    <asp:DropDownList ID="DropDownList1" runat="server"
    DataSourceID="SqlDataSource2"

    DataTextField="CategoryName" DataValueField="CategoryID" SelectedValue='<%#
    Bind("CategoryID") %>' >

    </asp:DropDownList>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    </Columns>

    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

    <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"
    />

    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
    />

    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

    <AlternatingRowStyle BackColor="White" />

    <RowStyle BackColor="#EFF3FB" />

    <EditRowStyle BackColor="#2461BF" />

    </asp:GridView>

    </form>

    </body>

    </html>
     
    verci, Sep 3, 2006
    #1
    1. Advertising

  2. verci

    verci Guest

    Hey thaks!!, that did it.


    "Gaurav Vaish (www.EduJini.IN)" <> wrote
    in message news:...
    > 1. Use EditCommandColumn
    > 2. Use the FooterText property of the EditCommandColumn class
    >
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish | http://www.mastergaurav.com
    > http://www.edujini.in | http://articles.edujini.in/webservices
    > -------------------
    >
    >
    > "verci" <> wrote in message
    > news:um$...
    >> Hi
    >> Can anyone help me or point me in the right direction, I'm running Win
    >> XP
    >> Pro SP2, VS2005 Team, .Net Framework
    >> 2.0 and SQL Server2005.
    >>
    >> I want to put a command button in the footer just below the links for
    >> edit
    >> and delete autogenerated by the gridview, this because I want to open
    >> another aspx page when the this button is pressed, my control code is
    >> below.
    >>
    >> Best Regards

    >
    >
     
    verci, Sep 3, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NewTel
    Replies:
    1
    Views:
    1,034
    Andrew Robinson
    Feb 9, 2006
  2. NewTel

    add Another row to GridView Footer-

    NewTel, Feb 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    9,149
    Andrew Robinson
    Feb 9, 2006
  3. verci

    Newbie, add a button to gridview footer

    verci, Sep 3, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    163
    verci
    Sep 3, 2006
  4. Colin Basterfield

    Add button in Footer of EditCommandColumn

    Colin Basterfield, Jan 15, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    177
    Colin Basterfield
    Jan 15, 2004
  5. Henrik
    Replies:
    1
    Views:
    460
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page