Click here to Skip to main content
16,012,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,

I have gridview column,(Imagebutton and Label)

inside Two controls are there Imagebutton and Label.

How i hide imagebutton when label is Show or
how i show imagebutton when label is hide.


how to solve this solutions give me answers.

Note: These 2 controls are located in single column of GridView.


by mohan.
Posted
Updated 25-Nov-11 18:15pm
v2

Hi,

Here is your code:

foreach(GridViewRow row in GridView1.Rows)
{
   if(row.Cells[0].Visible == true)
   {
      row.Cells[1].Visible = false;
   }
   else if(row.Cells[1].Visible == true)
   {
      row.Cells[0].Visible = false;
   }
}


Please mark this as answered this fixed your problem

Best regards,
Eduard
 
Share this answer
 
hi.....

Now you need to use the databinding event for this functionality

C#
protected void GridView1_DataBinding(object sender, EventArgs e)
    {

        int i = 0;
        foreach (GridViewRow row in GridView1.Rows)
        {
            if (row.RowIndex % 2 == 0)
            {
                ((Label)row.FindControl("Label1")).Text = "odd";
            }
            else
            {
                ((Label)row.FindControl("Label1")).Text = "even";
            }

            i++;
        }

    }



in this user can set any property of the control.

Here is the example of Text Property you can use any condition and based on that set the visibility property also.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900