问题描述
尊敬的先生,
我有gridview列,(图像按钮和标签)
内部有两个控件,分别是Imagebutton和Label.
当标签为显示"或"
"时,如何隐藏图像按钮标签隐藏时如何显示imagebutton.
如何解决该解决方案给了我答案.
注意:这2个控件位于GridView的单列中.
由mohan.
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.
推荐答案
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
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.
这篇关于如何在grideview SINGLE列中隐藏两个控件的第一个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!