Passing values from 2 dropdown boxes
I have two different dropdown boxes with prefilled selection items. I am trying to pass all of the users selected items and return data based on it. I am able to retrieve data based on开发者_如何学C the first dropdown list but for the second dropdown 'null' gets passed in. Here is my code:
resultSummaryViewModel.ReportFrame = new FramedViewModel();
if (string.IsNullOrEmpty(resultSummaryViewModel.Value)) return;
string viewValue = resultSummaryViewModel.Value.Substring(0, resultSummaryViewModel.Value.IndexOf("|"));
string viewType = resultSummaryViewModel.Value.Substring(resultSummaryViewModel.Value.IndexOf("|") + 1);
//if (string.IsNullOrEmpty(resultSummaryViewModel.CValue)) return;
string cTypeValue = resultSummaryViewModel.CValue.Substring(0, resultSummaryViewModel.CValue.IndexOf("|"));
string cType = resultSummaryViewModel.CValue.Substring(resultSummaryViewModel.CValue.IndexOf("|") + 1);
resultSummaryViewModel.ReportFrame.SourceURL = WebPathHelper.MapUrlFromRoot(
string.Format("Reporting/ResultSummary.aspx?beginDate={0}&endDate={1}&Id={2}&viewType={3}&cTypeValue={4}&cType={5}",
resultSummaryViewModel.BeginDate,
resultSummaryViewModel.EndDate,
viewValue,viewType,
cTypeValue,cType));
If there is another way to get back selected items from lists that would be great also. Thanks.
I had to encode my selection before passing it in the url as so :
string caseType = null;
if (!String.IsNullOrEmpty(viewModel.CaseTypeValue))
{
caseType = HttpUtility.UrlEncode(viewModel.CaseTypeValue, System.Text.Encoding.Default);
}
that worked well for me from there
精彩评论