I'm using an ObjectDataSource to populate a DropDownList. What I want to do is only display the table row that contains this DropDownList if the ObjectDataSource returns results. If it doesn't return any records to populate the DropDownList, I don't want to display the table row.
So I have wrapped the table row in a div tag, then figured I could use the Visible property to toggle its display.
Here's what I have so far:
Then in the codebehind I figure I need an if statement...
I'm just not sure how to reference the ObjectDataSource, or if that's even what I need to reference to make this work.
Any help would be much appreciated. Thanks!
So I have wrapped the table row in a div tag, then figured I could use the Visible property to toggle its display.
Here's what I have so far:
Code:
<asp:ObjectDataSource ID="SuppliersDS" runat="server"
SelectMethod="GetSuppliersByUserLogin" TypeName="DataAccess.APSupplierInvoiceSystem">
<SelectParameters>
<asp:SessionParameter Name="UserLogin" SessionField="USER_NAME" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<table cellpadding="5" border="0" width="100%">
<div runat="server" id="supplierDD">
<tr>
<td width="15%">Supplier:</td>
<td width="85%"><asp:DropDownList ID="ddlSupplier" runat="server"
DataTextField="vendor_name"
DataValueField="vendor_id" CausesValidation="true"
DataSourceID="SuppliersDS" >
</asp:DropDownList></td>
</tr>
</div>
...
Code:
if ()
{
this.supplierDD.Visible = true;
}
else
{
this.supplierDD.Visible = false;
}
Any help would be much appreciated. Thanks!