G
Guest
I'm using the DataList and GridView controls, and I am trying to wrap my
head around the problem of conditionally showing or hiding cells/cell
content based on the presence or absence of DB data. I am finding this sort
of problem by far the most annoying part about working with ASP.NET
controls.
What I want is to know how to do three things:
- conditionally show or hide an ImageField +column+ based on whether or not
an the ImageField's DataImageUrlField is empty or not
-conditionally show or hide an TemplateField based on whether a DB field
associated with the row was empty or not. (In this scenario, an Image
control would be embedded in the ItemTemplate.
-conditionally show or hide an Image control based on whether a DB field
containing the URL for the image was empty or not.
I understand how to declaratively call a function attached to the
RowDataBound event, and I know how to hide columns based or the presence or
absence of string data in those fields:
protected void GridView2_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.Cells[0].Text == "")
{
e.Row.Cells[0].Visible = false;
}
}
What do I need is the syntax to test for the Url's presence or absence in my
DB.
Thanks for any help you might be able to offer.
-KF
head around the problem of conditionally showing or hiding cells/cell
content based on the presence or absence of DB data. I am finding this sort
of problem by far the most annoying part about working with ASP.NET
controls.
What I want is to know how to do three things:
- conditionally show or hide an ImageField +column+ based on whether or not
an the ImageField's DataImageUrlField is empty or not
-conditionally show or hide an TemplateField based on whether a DB field
associated with the row was empty or not. (In this scenario, an Image
control would be embedded in the ItemTemplate.
-conditionally show or hide an Image control based on whether a DB field
containing the URL for the image was empty or not.
I understand how to declaratively call a function attached to the
RowDataBound event, and I know how to hide columns based or the presence or
absence of string data in those fields:
protected void GridView2_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.Cells[0].Text == "")
{
e.Row.Cells[0].Visible = false;
}
}
What do I need is the syntax to test for the Url's presence or absence in my
DB.
Thanks for any help you might be able to offer.
-KF