Monday, March 26, 2012

working with datasets and multiple dataviews

This posting has its roots in http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=695549. I'm starting a new post, because I think I've isolated the source of my problem.

Given the code:


sub Bind_AgentList()
dv_currAgents=ds_Agents.Tables(agentList).DefaultView
dv_currAgents.RowFilter = "agent_Status='CURR'"
dv_Agents=ds_Agents.Tables(agentList).DefaultView
dropdownlist_Agents.DataSource=dv_Agents
dropdownlist_Agents.DataBind()
dropdownlist_Agents.Items.Insert(0, new listitem("select agent name", ""))
end sub

Question: What should appear in the drop down list? The filtered or unfiltered data?
Answer: The filtered dataview is being used as the source for the dropdown

Question: WHY?! :-(Because the datasource for the dropdownlist is dv_Agents, which is unfiltered. If you want the filtered data, use dv_currAgents as the datasource for the dropdownlist.

0 comments:

Post a Comment