473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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.
Apr 4 '06 #1
2 1246
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>
<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.

Apr 4 '06 #2

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>
<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.

Apr 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pierrick | last post by:
Hello, I have a question about the possibility of using a DropDownList inside a GridView's column (by using a template column). I would like that each DropDownList's content (i.e. for each row)...
0
by: Oren | last post by:
Hello, why is the control: DropDownList can't do AutoSide-width in his Column. I mean if I have more Columns and I fill the DropDownList at the event: gridview_RowDataBound then the ...
5
by: Diane Truyens | last post by:
Hi, I have a form with textboxes, a search button and a gridview. The textboxes are filled with default values so that the gridview should return all rows but not before the user has had the...
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
3
by: S_K | last post by:
I have a GridView that has a DropDownList in one of the columns. When I edit and update any row I would like to grab the SelectedValue of that DropDownList when I'm in the GridView_RowUpdating...
0
by: Fabrizio | last post by:
Hi all. I have a field in a gridview as templatefield which is a label in view mode and a dropdownlist in edit mode with his datasource. This gridview is inserted as templatefield in another...
0
by: minhtran | last post by:
Hi everyone I have a problem when I want to edit the value from nested dropdownlist in Gridview, Please, anyone can help me to solve this problem, a great appreciation from me in advance. here is...
3
by: ata | last post by:
Hi folks, Consider the following code: protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow row = e.Row; if (row.RowType != DataControlRowType.DataRow)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.