I am writing a custom webpart that pulls information from a list and puts it into a radio button list. Then based on the persons choice another radio button list will appear with with more choices based on the previous choice with only the distinct values
displaying. The method below is for populating the second radiobutton list. The problem I am having is that the method is putting all of the list items into the radio button list, when it should only be putting the items pertaining to the choice.
ASPRonin
Member
6 Points
20 Posts
Custom Sharepoint Webpart with CAML Query help.
Jul 30, 2010 03:08 PM|LINK
I am writing a custom webpart that pulls information from a list and puts it into a radio button list. Then based on the persons choice another radio button list will appear with with more choices based on the previous choice with only the distinct values displaying. The method below is for populating the second radiobutton list. The problem I am having is that the method is putting all of the list items into the radio button list, when it should only be putting the items pertaining to the choice.
private void RetrieveCategory(string MainCategory){ SPSite spSite = new SPSite("http://testsite/sites/CRCHome/CRCAdmin/default.aspx"); SPWeb spWeb = spSite.OpenWeb(); SPList MyList = spWeb.Lists["MasterList"]; SPQuery query = new SPQuery(); query.Query = "<Query><Where><Eq><FieldRef Name='MainCategory' /> <Value Type='Text'>"+MainCategory+"</Value></Eq></Where></Query>"; DataTable tempTbl = MyList.GetItems(query).GetDataTable(); DataView tempView = new DataView(tempTbl); String[] columns = {"Category"}; DataTable tblCategory = tempView.ToTable(true, columns); for(int i = 0; i<tblCategory.Rows.Count ; i++) { DataRow CategoryItem = tblCategory.Rows[i]; rblCategories.Items.Add(CategoryItem["Category"].ToString()); } }