S
sjsean
If you have suggestions on how to display I'm all ears...just learning
gridview, detailsview, etc. and not sure how to make them display data
in "my" layout/format. Still accustomed to using asp classic.
I have placed a gridview on my page and want it to display address
information. However, sometimes the address information field in the
database will be null and I don't want the page to show a blank space.
Modified this from a page on the net, but it either shows all the
information including the blank line or it shows nothing and all of
this is depends on row.cells(0).visible = false
Example:
Name
address1
address2
city, state zip
telephone
for the most part address 2 would be blank/null so it should "hide".
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e
As System.EventArgs) Handles GridView1.DataBound
Dim row As GridViewRow
For Each row In GridView1.Rows
If String.IsNullOrEmpty(row.Cells(0).Text) Then
row.Cells(0).Visible = False
End If
Exit Sub
Next
End Sub
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<b><asp:Label ID="Label4" runat="server" Text='<%#
Bind("location_nickname") %>'></asp:Label></b><br />
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("location_add1") %>'></asp:Label><br />
<asp:Label ID="Label6" runat="server" Text='<%#
Bind("location_add2") %>'></asp:Label><br />
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("location_city") %>'></asp:Label>,
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("location_state") %>'></asp:Label><br />
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("location_zip") %>'></asp:Label><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
gridview, detailsview, etc. and not sure how to make them display data
in "my" layout/format. Still accustomed to using asp classic.
I have placed a gridview on my page and want it to display address
information. However, sometimes the address information field in the
database will be null and I don't want the page to show a blank space.
Modified this from a page on the net, but it either shows all the
information including the blank line or it shows nothing and all of
this is depends on row.cells(0).visible = false
Example:
Name
address1
address2
city, state zip
telephone
for the most part address 2 would be blank/null so it should "hide".
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e
As System.EventArgs) Handles GridView1.DataBound
Dim row As GridViewRow
For Each row In GridView1.Rows
If String.IsNullOrEmpty(row.Cells(0).Text) Then
row.Cells(0).Visible = False
End If
Exit Sub
Next
End Sub
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<b><asp:Label ID="Label4" runat="server" Text='<%#
Bind("location_nickname") %>'></asp:Label></b><br />
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("location_add1") %>'></asp:Label><br />
<asp:Label ID="Label6" runat="server" Text='<%#
Bind("location_add2") %>'></asp:Label><br />
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("location_city") %>'></asp:Label>,
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("location_state") %>'></asp:Label><br />
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("location_zip") %>'></asp:Label><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>