alphabetsoup2
New Member
So, I have rad list box that I bind in code-behind.\[code\] <telerik:RadListBox runat="server" Skin="Hay" ID="rlbSurveys" Style="float: right !important;" Width="300px" Height="100px" SelectionMode="Multiple" CheckBoxes="True" DataTextField="Name" DataValueField="ID" meta:resourcekey="listSurveysResource1"> <ButtonSettings TransferButtons="All" /> </telerik:RadListBox>\[/code\]Code behind looks like:\[code\]private void SurveysBind() { var surveyProvider = new SurveyProvider(); var selectedUserID = Guid.Parse(Membership.GetUser(rlbUsers.SelectedValue).ProviderUserKey.ToString()); var allSurveys = surveyProvider.GetAllSurveys() .Select(survey => new { survey.Name, survey.ID }) .OrderBy(survey => survey.Name); rlbSurveys.DataSource = allSurveys; rlbSurveys.DataBind(); var userSurveys = surveyProvider.GetSurveysByUserID(selectedUserID).Select(survey => new {survey.Name, survey.ID}); foreach (var userSurvey in userSurveys) { if(rlbSurveys.FindItemByValue(userSurvey.ID.ToString()) != null) { rlbSurveys.FindItemByValue(userSurvey.ID.ToString()).Checked = true; } }}\[/code\]Here I get all existing surveys in [var allSurveys] and populate them to my rad list box.Then I get all surveys user can observe in [var userSurveys].I want to check all rows in rad list box where I have match on ID with userSurveys.I did it with foreach and it works fine, but when I try it with linq I have an error \[quote\] Error 6 The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.\[/quote\]\[code\] userSurveys.Select(survey => { if(rlbSurveys.FindItemByValue(survey.ID.ToString()) != null) { rlbSurveys.FindItemByValue(survey.ID.ToString()).Checked = true; } });\[/code\]Now I wonder if there is better way to do it.