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


G

Guest

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>
<asp:DropDownList ID="RideDatesDropDownList" runat="server"
DataSourceId="RideDatesSqlDataSource" DataTextField="RideDate"
DataValueField="RideDate"
DataTextFormatString="{0:MMM yyyy}" CssClass="waDropDownList">
</asp:DropDownList>

Thanks for any clues on this.
 
Ad

Advertisements

G

Guest

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);
}
 
Ad

Advertisements

G

Guest

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

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

Ask a Question

Top