Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / October 2007

Tip: Looking for answers? Try searching our database.

Hiding grid columns based on some value in row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillG - 24 Oct 2007 15:41 GMT
I have a grid that has icons for 2 buttons edit and delete on each row.  I
would like to make the buttons invisible if the dateoccured in the record in
the row is older than this week.  How do I do that?

Bill
Mansi Shah - 27 Oct 2007 08:42 GMT
Hi,

To change the visibility of any button or any control based on some
condition in grid, you can create 1 function after binding the grid.
Say,

.
grdcustomers.databind();
CheckGridForVisibility();

add this function to your page..

public void CheckGridForVisibility()
{
 for (int i = 0; i < grdCustomers.Rows.Count; i++)
       {
           Label lbldatetime =
(Label)grdCustomers.Rows[i].FindControl("lblDataTime");
       if (lbldatetime.Text == DateTime.Today.ToString())
           {
               Button btnedit =
grdCustomers.Rows[i].FindControl("btnEdit");
               btnedit.Visible = false;
           }
       }
}

Hope this will help you..

Regards,
Mansi Shah.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.