Obout Grid:仅在特定行的网格上隐藏图像
Obout Grid: Hiding an Image on a grid for certain rows only
使用带有以下列的 obout 网格:
<obg:Column ID="Image" DataField="" HeaderText="" Width="50" runat="server">
<TemplateSettings TemplateId="ImageTemplate" />
</obg:Column>
以及以下模板:
<Templates>
<obg:GridTemplate runat="server" ID="ImageTemplate">
<Template>
<img src="images/test.png" title="test" />
</Template>
</obg:GridTemplate>
</Templates>
我正在尝试以编程方式隐藏某些行上的图像:
protected void grd_RowDataBound(object sender, GridRowEventArgs e)
{
if (testpassed())
{
e.Row.Cells[1].Text = ""; // Column 2 is the image
}
}
但它并没有隐藏图像。如何仅对某些行使用 obout 网格以编程方式隐藏图像?在此先致谢。
如果找到答案以防将来有人遇到此问题:
protected void grd_RowDataBound(object sender, GridRowEventArgs e)
{
// Check if this is a DataRow
if (e.Row.RowType == GridRowType.DataRow)
{
// Check if we are hiding the image
if (testpassed())
{
// Retrieve Image Cell (Column 2 in my case)
GridDataControlFieldCell cell = e.Row.Cells[1] as GridDataControlFieldCell;
// Retrieve Literal Control with Image Source Html (Found at Level 5)
LiteralControl imgTag = cell.Controls[0].Controls[0].Controls[0].Controls[0].Controls[0] as LiteralControl;
// Remove Html <img src.. code from Literal Control in order to hide image
imgTag.Text = "";
}
}
}
使用带有以下列的 obout 网格:
<obg:Column ID="Image" DataField="" HeaderText="" Width="50" runat="server">
<TemplateSettings TemplateId="ImageTemplate" />
</obg:Column>
以及以下模板:
<Templates>
<obg:GridTemplate runat="server" ID="ImageTemplate">
<Template>
<img src="images/test.png" title="test" />
</Template>
</obg:GridTemplate>
</Templates>
我正在尝试以编程方式隐藏某些行上的图像:
protected void grd_RowDataBound(object sender, GridRowEventArgs e)
{
if (testpassed())
{
e.Row.Cells[1].Text = ""; // Column 2 is the image
}
}
但它并没有隐藏图像。如何仅对某些行使用 obout 网格以编程方式隐藏图像?在此先致谢。
如果找到答案以防将来有人遇到此问题:
protected void grd_RowDataBound(object sender, GridRowEventArgs e)
{
// Check if this is a DataRow
if (e.Row.RowType == GridRowType.DataRow)
{
// Check if we are hiding the image
if (testpassed())
{
// Retrieve Image Cell (Column 2 in my case)
GridDataControlFieldCell cell = e.Row.Cells[1] as GridDataControlFieldCell;
// Retrieve Literal Control with Image Source Html (Found at Level 5)
LiteralControl imgTag = cell.Controls[0].Controls[0].Controls[0].Controls[0].Controls[0] as LiteralControl;
// Remove Html <img src.. code from Literal Control in order to hide image
imgTag.Text = "";
}
}
}