Moorkepupelry
New Member
I have a ListView with DataPager control. I'm trying to display a series of questions.Each question along with it's choices belongs to an item in the listview and I am displaying one question per page. The choices are radio buttons with autopostback enabled.Now, based on the user's response to the first question I want to filter the rest of the questions in the listview to display only the ones relevant to the user's choice. Also, I don't want to completely remove the other questions from the listview because if the user navigates to the first question and changes his response, I want the list to change accordingly. Is there a way to dynamically hide the pages that contain the irrelevant questions?Thanks. Note: The list items are populated by a custom sql query:\[code\]SELECT questionNumber,questionText,OptionA,OptionB,OptionC,OptionD,OptionE,OptionF,OptionG,OptionH,OptionI,OptionJ,OptionK,OptionL,Other,questionTag,subType from Questionairre\[/code\]In this query the value present in the field "subType" should be compared with the choice made in the first question.. The subtype field for the first question will not be checked. The following code is what I have so far. The variable "firstChoice" is the static variable that stores the value postedback from the first question.\[code\] protected void ListView_ItemDataBound(object sender, ListViewItemEventArgs e) { SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); ListViewDataItem di = (ListViewDataItem)e.Item; Label q=new Label(); foreach(Control control in di.Controls) { if (control.GetType() == typeof(Label)) { q = (Label)control; if (q.ID == "subType" && q.Text != firstChoice) { di.Visible = false; } } } }\[/code\]