SqlDataSource used multiple times
Posted on 2007-08-02
I'm trying to use an SqlDataSource to populate several drop down lists in a gridview. I assume there's a way to just use one datasource and reset it's properties but I can't get it to work. Here's what I have:
SqlDataSource2.SelectCommand = "app_InvoiceVendors_GetAll"
ddlVendor.DataTextField = "VendorName"
ddlVendor.DataValueField = "VendorID"
Dim liVendor As ListItem = ddlVendor.Items.FindByText(sVendor)
liVendor.Selected = True
Dim ddlProjectAIT As DropDownList = e.Row.Controls(5).FindControl("ddlProjectAIT")
SqlDataSource2.SelectCommand = "app_Projects_GetforInvoice"
ddlProjectAIT.DataTextField = "ProjectName"
ddlProjectAIT.DataValueField = "ProjectID"
Dim liProjectAIT As ListItem = ddlProjectAIT.Items.FindByText(sProjectAIT)
liProjectAIT = ddlProjectAIT.Items.FindByText(sProjectAIT)
liProjectAIT.Selected = True
Works fine on the first pass but bombs out on the second. Any thoughts