Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > prevent DropDownList from displaying in GridView column if it's em

Reply
Thread Tools

prevent DropDownList from displaying in GridView column if it's em

 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      04-04-2006
I have a number of rows in a GridView Column which don't have values for the
DropDownList, is there a way to hide the control if it has no data?

Here's my code:
<ItemTemplate>
<aspropDownList ID="RideDatesDropDownList" runat="server"
DataSourceId="RideDatesSqlDataSource" DataTextField="RideDate"
DataValueField="RideDate"
DataTextFormatString="{0:MMM yyyy}" CssClass="waDropDownList">
</aspropDownList>

Thanks for any clues on this.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      04-04-2006
Consume the DataBound event of the dropdownlist, e.g.
OnDataBound="ShowHideDDL"

Then write a protected method in the codebehind like this:
protected void ShowHideDDL(object sender, EventArgs e)
{
DropDownList ddl= (DropDownList) sender;
ddl.Visible= (ddl.Items.Count>0);
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Dabbler" wrote:

> I have a number of rows in a GridView Column which don't have values for the
> DropDownList, is there a way to hide the control if it has no data?
>
> Here's my code:
> <ItemTemplate>
> <aspropDownList ID="RideDatesDropDownList" runat="server"
> DataSourceId="RideDatesSqlDataSource" DataTextField="RideDate"
> DataValueField="RideDate"
> DataTextFormatString="{0:MMM yyyy}" CssClass="waDropDownList">
> </aspropDownList>
>
> Thanks for any clues on this.

 
Reply With Quote
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      04-04-2006

Wow Phillip, that was simple and worked on the first try! So many events, so
little time. Thanks much.

"Phillip Williams" wrote:

> Consume the DataBound event of the dropdownlist, e.g.
> OnDataBound="ShowHideDDL"
>
> Then write a protected method in the codebehind like this:
> protected void ShowHideDDL(object sender, EventArgs e)
> {
> DropDownList ddl= (DropDownList) sender;
> ddl.Visible= (ddl.Items.Count>0);
> }
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Dabbler" wrote:
>
> > I have a number of rows in a GridView Column which don't have values for the
> > DropDownList, is there a way to hide the control if it has no data?
> >
> > Here's my code:
> > <ItemTemplate>
> > <aspropDownList ID="RideDatesDropDownList" runat="server"
> > DataSourceId="RideDatesSqlDataSource" DataTextField="RideDate"
> > DataValueField="RideDate"
> > DataTextFormatString="{0:MMM yyyy}" CssClass="waDropDownList">
> > </aspropDownList>
> >
> > Thanks for any clues on this.

 
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 Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying dropdownlist selected data in the Gridview using the objecy datasource mr.smiley ASP .Net 0 04-21-2011 12:37 PM
Displaying HTML inside a GridView Column - PLEASE HELP BillGatesFan ASP .Net 0 07-23-2008 10:42 PM
DropDownList in GridView column no declared in Button_Click James ASP .Net Web Controls 1 04-01-2008 11:53 PM
ASP.net GridView with a dropdownList in atemplate column aidoCo Software 3 09-20-2007 08:44 PM
How to initialize dropdownlist value in a gridview column edit template keithb ASP .Net 2 06-02-2006 09:58 PM



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