Dropdown in footer template of datagrid

Discussion in 'ASP .Net Datagrid Control' started by Edward Bills, Jul 16, 2004.

  1. Edward Bills

    Edward Bills Guest

    I have been able to create and populate dropdowns in both the item template
    tag and the edit template tag. When I try to add one to the footer the
    function I have inserted into the datasource tag never gets called. What is
    the proper way to populate a dropdown in the Footer Template of a DataGrid?

    Thanks
    Ed
     
    Edward Bills, Jul 16, 2004
    #1
    1. Advertising

  2. in your itemdatabound eventhandler, are you checking if the cell is of type
    footer?


    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Edward Bills" <> wrote in message
    news:...
    >I have been able to create and populate dropdowns in both the item template
    > tag and the edit template tag. When I try to add one to the footer the
    > function I have inserted into the datasource tag never gets called. What
    > is
    > the proper way to populate a dropdown in the Footer Template of a
    > DataGrid?
    >
    > Thanks
    > Ed
    >
    >
     
    Alvin Bruney [MVP], Jul 18, 2004
    #2
    1. Advertising

  3. Edward Bills

    Edward Bills Guest

    First I Just tried calling a function from the HTML code in the datasource
    tag of the list box (The function GetAgencies returns a datatable, and the
    following code works great in an edittemplate tag):

    <FooterTemplate>
    <asp:DropDownList runat="server" lstAddAgencies"
    DataValueField="Code" DataTextField="Description" DataSource="<%#
    GetAgencies() %>"></asp:DropDownList>
    </FooterTemplate>

    I then tried the following code:

    Sub C1WebGrid2_ItemDataBound(ByVal sender As Object, ByVal e As
    C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid2.ItemDataBound
    If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then
    lstAddAgencies.DataSource = GetAgencies()
    lstAddAgencies.DataBind()
    lstAddNames.DataSource = GetNames()
    lstAddNames.DataBind()
    End If
    End Sub

    Neither of the above methods will populate the dropdowns in the footer.



    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:%...
    > in your itemdatabound eventhandler, are you checking if the cell is of

    type
    > footer?
    >
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "Edward Bills" <> wrote in message
    > news:...
    > >I have been able to create and populate dropdowns in both the item

    template
    > > tag and the edit template tag. When I try to add one to the footer the
    > > function I have inserted into the datasource tag never gets called.

    What
    > > is
    > > the proper way to populate a dropdown in the Footer Template of a
    > > DataGrid?
    > >
    > > Thanks
    > > Ed
    > >
    > >

    >
    >
     
    Edward Bills, Jul 19, 2004
    #3
  4. for your last function you will need to set the datatextstring property to
    the value of the column you want to display otherwise it won't show

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Edward Bills" <> wrote in message
    news:...
    > First I Just tried calling a function from the HTML code in the datasource
    > tag of the list box (The function GetAgencies returns a datatable, and the
    > following code works great in an edittemplate tag):
    >
    > <FooterTemplate>
    > <asp:DropDownList runat="server" lstAddAgencies"
    > DataValueField="Code" DataTextField="Description" DataSource="<%#
    > GetAgencies() %>"></asp:DropDownList>
    > </FooterTemplate>
    >
    > I then tried the following code:
    >
    > Sub C1WebGrid2_ItemDataBound(ByVal sender As Object, ByVal e As
    > C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid2.ItemDataBound
    > If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then
    > lstAddAgencies.DataSource = GetAgencies()
    > lstAddAgencies.DataBind()
    > lstAddNames.DataSource = GetNames()
    > lstAddNames.DataBind()
    > End If
    > End Sub
    >
    > Neither of the above methods will populate the dropdowns in the footer.
    >
    >
    >
    > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > news:%...
    >> in your itemdatabound eventhandler, are you checking if the cell is of

    > type
    >> footer?
    >>
    >>
    >> --
    >> Regards,
    >> Alvin Bruney
    >> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    >> Got tidbits? Get it here... http://tinyurl.com/27cok
    >> "Edward Bills" <> wrote in
    >> message
    >> news:...
    >> >I have been able to create and populate dropdowns in both the item

    > template
    >> > tag and the edit template tag. When I try to add one to the footer the
    >> > function I have inserted into the datasource tag never gets called.

    > What
    >> > is
    >> > the proper way to populate a dropdown in the Footer Template of a
    >> > DataGrid?
    >> >
    >> > Thanks
    >> > Ed
    >> >
    >> >

    >>
    >>

    >
    >
     
    Alvin Bruney [MVP], Jul 19, 2004
    #4
  5. Edward Bills

    Scott G. Guest

    This code works for me:

    <%@ Page language="c#" AutoEventWireup="False" Trace="true" %>
    <html>
    <head>
    <script language="C#" runat="server">
    protected override void OnLoad(EventArgs e)
    {
    System.Collections.ArrayList list = new System.Collections.ArrayList();
    list.Add("hi");
    list.Add("there");
    DG.DataSource = list;
    DG.DataBind();
    }

    protected System.Data.DataTable GetAgencies()
    {
    System.Data.DataTable t = new System.Data.DataTable();
    t.Columns.Add("code");
    t.Columns.Add("description");
    System.Data.DataRow row = t.NewRow();
    row["code"] = "1";
    row["description"] = "one";
    t.Rows.Add(row);
    row = t.NewRow();
    row["code"] = "2";
    row["description"] = "two";
    t.Rows.Add(row);
    return t;
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid id="DG" runat="server" autogeneratecolumns="False" showfooter="True" showheader="False">
    <columns>
    <asp:templatecolumn>
    <itemtemplate>
    <asp:label runat="server" text="Foo"></asp:label>
    </itemtemplate>
    <footertemplate>
    <asp:dropdownlist runat="server"
    DataValueField="code" DataTextField="description"
    DataSource="<%# GetAgencies() %>" id="Dropdownlist1"></asp:dropdownlist>
    </footertemplate>
    </asp:templatecolumn>
    </columns>
    </asp:datagrid>
    </form>
    </body>
    </html>
    "Edward Bills" <> wrote in message news:...
    First I Just tried calling a function from the HTML code in the datasource
    tag of the list box (The function GetAgencies returns a datatable, and the
    following code works great in an edittemplate tag):

    <FooterTemplate>
    <asp:DropDownList runat="server" lstAddAgencies"
    DataValueField="Code" DataTextField="Description" DataSource="<%#
    GetAgencies() %>"></asp:DropDownList>
    </FooterTemplate>

    I then tried the following code:

    Sub C1WebGrid2_ItemDataBound(ByVal sender As Object, ByVal e As
    C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid2.ItemDataBound
    If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then
    lstAddAgencies.DataSource = GetAgencies()
    lstAddAgencies.DataBind()
    lstAddNames.DataSource = GetNames()
    lstAddNames.DataBind()
    End If
    End Sub

    Neither of the above methods will populate the dropdowns in the footer.



    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:%...
    > in your itemdatabound eventhandler, are you checking if the cell is of

    type
    > footer?
    >
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "Edward Bills" <> wrote in message
    > news:...
    > >I have been able to create and populate dropdowns in both the item

    template
    > > tag and the edit template tag. When I try to add one to the footer the
    > > function I have inserted into the datasource tag never gets called.

    What
    > > is
    > > the proper way to populate a dropdown in the Footer Template of a
    > > DataGrid?
    > >
    > > Thanks
    > > Ed
    > >
    > >

    >
    >
     
    Scott G., Jul 19, 2004
    #5
  6. Edward Bills

    Edward Bills Guest

    I think it is just a problem with the component one datagrid I am using, because it works fine with the regular datagrid control. Thanks for the help.
    "Scott G." <> wrote in message news:%23Pv$...
    This code works for me:

    <%@ Page language="c#" AutoEventWireup="False" Trace="true" %>
    <html>
    <head>
    <script language="C#" runat="server">
    protected override void OnLoad(EventArgs e)
    {
    System.Collections.ArrayList list = new System.Collections.ArrayList();
    list.Add("hi");
    list.Add("there");
    DG.DataSource = list;
    DG.DataBind();
    }

    protected System.Data.DataTable GetAgencies()
    {
    System.Data.DataTable t = new System.Data.DataTable();
    t.Columns.Add("code");
    t.Columns.Add("description");
    System.Data.DataRow row = t.NewRow();
    row["code"] = "1";
    row["description"] = "one";
    t.Rows.Add(row);
    row = t.NewRow();
    row["code"] = "2";
    row["description"] = "two";
    t.Rows.Add(row);
    return t;
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid id="DG" runat="server" autogeneratecolumns="False" showfooter="True" showheader="False">
    <columns>
    <asp:templatecolumn>
    <itemtemplate>
    <asp:label runat="server" text="Foo"></asp:label>
    </itemtemplate>
    <footertemplate>
    <asp:dropdownlist runat="server"
    DataValueField="code" DataTextField="description"
    DataSource="<%# GetAgencies() %>" id="Dropdownlist1"></asp:dropdownlist>
    </footertemplate>
    </asp:templatecolumn>
    </columns>
    </asp:datagrid>
    </form>
    </body>
    </html>
    "Edward Bills" <> wrote in message news:...
    First I Just tried calling a function from the HTML code in the datasource
    tag of the list box (The function GetAgencies returns a datatable, and the
    following code works great in an edittemplate tag):

    <FooterTemplate>
    <asp:DropDownList runat="server" lstAddAgencies"
    DataValueField="Code" DataTextField="Description" DataSource="<%#
    GetAgencies() %>"></asp:DropDownList>
    </FooterTemplate>

    I then tried the following code:

    Sub C1WebGrid2_ItemDataBound(ByVal sender As Object, ByVal e As
    C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid2.ItemDataBound
    If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then
    lstAddAgencies.DataSource = GetAgencies()
    lstAddAgencies.DataBind()
    lstAddNames.DataSource = GetNames()
    lstAddNames.DataBind()
    End If
    End Sub

    Neither of the above methods will populate the dropdowns in the footer.



    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:%...
    > in your itemdatabound eventhandler, are you checking if the cell is of

    type
    > footer?
    >
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "Edward Bills" <> wrote in message
    > news:...
    > >I have been able to create and populate dropdowns in both the item

    template
    > > tag and the edit template tag. When I try to add one to the footer the
    > > function I have inserted into the datasource tag never gets called.

    What
    > > is
    > > the proper way to populate a dropdown in the Footer Template of a
    > > DataGrid?
    > >
    > > Thanks
    > > Ed
    > >
    > >

    >
    >
     
    Edward Bills, Jul 22, 2004
    #6
    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. =?Utf-8?B?VGltOjouLg==?=

    GURU HELP??? Dropdown List in Datagrid Footer

    =?Utf-8?B?VGltOjouLg==?=, Sep 22, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    822
    =?Utf-8?B?VGltOjouLg==?=
    Sep 23, 2004
  2. vishnu
    Replies:
    1
    Views:
    1,217
    Patrick.O.Ige
    Mar 25, 2006
  3. Daniel Roth
    Replies:
    0
    Views:
    256
    Daniel Roth
    Apr 5, 2005
  4. Henrik
    Replies:
    1
    Views:
    433
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
  5. Donald Welker

    Update Textbox from adjacent dropdown in datagrid custom template

    Donald Welker, Aug 9, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    249
    Donald Welker
    Aug 10, 2005
Loading...

Share This Page