Dataview Rowfilter setting adds blank records to the dropdown control when I use Databind

  • Thread starter Mohan Sundaram via .NET 247
  • Start date
M

Mohan Sundaram via .NET 247

Hello,

I'm using a Dataview object to Databind a set of data items tocouple of drop down controls, but I have a problem with theRowfilter property of the dataview. It filters the row I don'twant to show but I still see blank rows added to the drop-down.I'm banging my head against the wall since y'day. I think it'ssomething to do with the fact that I'm storing the dataviewobject as a Session objeect and updating the row filter when Ihave to.

here's brief overview of what I'm doing, I got three drop downson a page. All databound to a diff set of dataview. When theuser selection is made on the first drop-down, I want to filterthe 2nd and 3rd drop down based on that. So, I'm retrieving allthe possible values for 2nd and 3rd drop down in PageLoad eventand store the view in a Session object, on the 1st dropdownindex changed event, I'm just setting the rowfilter for 2nd and3rd drop-down's dataview and rebinding it to the control. Itseems to work as expected except I see unwanted blank rows inthose drop-downs. I stepped thru' in debug mode, I can see thatdataview count is set to right value as expected (I don't knowhow to open the dataview object in the immediate window and seethe contents though... the tree keeps going down but I can neverget to the data).... Anyone has any clue what could be wronghere.. here's the code on I'm using to databind.

Here, 'view' is declared as a global object in that aspx page asDim view As Dataview. dSID is the first drop down I was talkingabout and dTID and dFID are the second and third drop down. Itried to set the RowStateFilter, it doesn't seem to have anyeffect.

view = Session("TView")

view.RowFilter = "LOCATION_ID=" &dSID.SelectedItem.Value.ToString
view.RowStateFilter = DataViewRowState.CurrentRows
view.Sort = "TEAM_ID"


dTID.DataSource = view
dTID.DataTextField = "TEAM_ABBR"
dTID.DataValueField = "TEAM_ID"

dTID.DataBind()

view = Session("FView")

view.RowFilter = "LOCATION_ID = " &dSID.SelectedItem.Value.ToString
view.Sort = "FUNCTION_ID"

dFID.DataSource = view
dFID.DataTextField = "FUNCTION_ABBR"
dFID.DataValueField = "FUNCTION_ID"

dFID.DataBind()

dTID.Items.Insert(0, "Select Team")
dFID.Items.Insert(0, "Select Function")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top