HighTechTalks DotNet Forums  

Hiding grid columns based on some value in row

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Hiding grid columns based on some value in row in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
BillG
 
Posts: n/a

Default Hiding grid columns based on some value in row - 10-24-2007 , 10:41 AM






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


Reply With Quote
  #2  
Old   
Mansi Shah
 
Posts: n/a

Default Re: Hiding grid columns based on some value in row - 10-27-2007 , 03:42 AM







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.

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.