Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Dropdown in footer template of datagrid

Reply
Thread Tools

Dropdown in footer template of datagrid

 
 
Edward Bills
Guest
Posts: n/a
 
      07-16-2004
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


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      07-18-2004
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
>
>



 
Reply With Quote
 
 
 
 
Edward Bills
Guest
Posts: n/a
 
      07-19-2004
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>
<aspropDownList runat="server" lstAddAgencies"
DataValueField="Code" DataTextField="Description" DataSource="<%#
GetAgencies() %>"></aspropDownList>
</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
> >
> >

>
>



 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      07-19-2004
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>
> <aspropDownList runat="server" lstAddAgencies"
> DataValueField="Code" DataTextField="Description" DataSource="<%#
> GetAgencies() %>"></aspropDownList>
> </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
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Scott G.
Guest
Posts: n/a
 
      07-19-2004
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>
<aspropDownList runat="server" lstAddAgencies"
DataValueField="Code" DataTextField="Description" DataSource="<%#
GetAgencies() %>"></aspropDownList>
</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
> >
> >

>
>



 
Reply With Quote
 
Edward Bills
Guest
Posts: n/a
 
      07-22-2004
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>
<aspropDownList runat="server" lstAddAgencies"
DataValueField="Code" DataTextField="Description" DataSource="<%#
GetAgencies() %>"></aspropDownList>
</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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to reorder how a datagrid is drawn (header/footer/items vs.header/items/footer)? Henrik ASP .Net Datagrid Control 1 07-06-2006 12:23 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Update Textbox from adjacent dropdown in datagrid custom template Donald Welker ASP .Net Web Controls 2 08-10-2005 07:41 PM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
GURU HELP??? Dropdown List in Datagrid Footer =?Utf-8?B?VGltOjouLg==?= ASP .Net 2 09-23-2004 06:43 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57