i use x.pagedlist component paging in asp.net mvc. create query , data database send data view , foreach printed on view. data represent in foreach first row second row exception(+ $exception {"index out of range. must non-negative , less size of collection.\r\nparameter name: index"} system.argumentoutofrangeexception ).i debug code , see model valid , print 2 parameter of second row on view , third parameter exception. delete third parameter , same exception in second parameter.
@using x.pagedlist.mvc @model x.pagedlist.ipagedlist<meydanmvc.models.advertisement> @{ var = 0; var groupservicebag = viewbag.groupserviceid; var subjectbag = viewbag.subjectid; var typeservicebag = viewbag.typeserviceid; var countybag = viewbag.countyid; var statebag = viewbag.stateid; var ocasionbag = viewbag.ocasion; } @foreach (var item in model) { i++; if (i == 3) { <hr /> <div class="row"> <div class="col-md-12"> <div class="margin-10"> باکس خبر </div> </div> </div> <hr /> <div class="row dark-border"> <div class="col-md-6"> <div class="box-advertising">باکس تبلیغات</div> </div> <div class="col-md-6"> <div class="box-advertising">باکس تبلیغات</div> </div> </div> } if (item.occasionflag) { <hr /> <div class="row ocasion-row"> <div class="col-md-1"> <div class="row"> <img src="~/image/okaziyon.png" /> </div> <div class="row"></div> <div class="row"></div> </div> <a href="~/advertisements/details/@item.id" class="black-color"> <div class="col-md-9 text-float"> <div class="row"> <div class="col-md-12 margin-right-14"> @html.displayfor(modelitem => item.stradvertisementtitle) <label for="advertisement">:عنوان آگهی</label> </div> </div> <div class="row"> <div class="description-height margin-right-14"> @html.displayfor(modelitem => item.discription) <label for="discription">:توضیحات</label> </div> </div> <br /> @*@html.displayfor(modelitem => item.wage.budge) <label for="wage-budge">:مبلغ</label>*@ <div class="row"> <div class="text-center"> @html.displayfor(modelitem => item.inserttime) <label for="inserttime">:زمان درج آگهی</label> </div> </div> </div> </a> <div class="col-md-2 img-advertisement1"> <a href=@url.content(@item.pictures[0].strpicturepath) data-toggle="lightbox"> <img src=@url.content(@item.pictures[0].strpicturepath) class="img-fluid" width="146" height="138"> </a> </div> </div> } else { <hr /> <div class="row heigh-161"> <div class="col-md-1"> </div> <a href="~/advertisements/details/@item.id" class="black-color"> <div class="col-md-9 text-float"> <div class="row"> <div class="col-md-12 margin-right-14"> @html.displayfor(modelitem => item.stradvertisementtitle) <label for="advertisement">:عنوان آگهی</label> </div> </div> <div class="row"> <div class="description-height margin-right-14"> @html.displayfor(modelitem => item.discription) <label for="discription">:توضیحات</label> </div> </div> <br /> @*@html.displayfor(modelitem => item.wage.budge) <label for="wage-budge">:مبلغ</label>*@ <div class="row"> <div class="text-center"> @html.displayfor(modelitem => item.inserttime) <label for="inserttime">:زمان درج آگهی</label> </div> </div> </div> </a> <div class="col-md-2 img-advertisement-simple"> <a href=@url.content(@item.pictures[0].strpicturepath) data-toggle="lightbox"> <img src=@url.content(@item.pictures[0].strpicturepath) class="img-fluid" height="138" width="146"> </a> </div> </div> } } <div class="row"> <div class="col-md-4"></div> <div class="col-md-4"> @html.pagedlistpager(model, page => url.action("index", "advertisements", new { page, groupserviceid = groupservicebag, subjectid = subjectbag, typeserviceid = typeservicebag, stateid = statebag, countyid = countybag, ocasion = ocasionbag }), pagedlistrenderoptions.enableunobtrusiveajaxreplacing(pagedlistrenderoptions.onlyshowfivepagesatatime, new ajaxoptions { httpmethod = "get", updatetargetid = "adver-list" })) </div> <div class="col-md-4"></div> </div>
my action
// get: advertisements [breadcrumb(title = "نمایش تبلیغات", order = 1)] public virtual actionresult index(int? page, string groupserviceid, string subjectid, string typeserviceid, string stateid, string countyid, string ocasion, string searchbox) { viewbag.groupservices = _dal.getallgroupservices(); viewbag.subjects = _dal.getallsubject(); viewbag.typeservices = _dal.getalltypeservice(); viewbag.states = _dal.getallstate(); viewbag.counties = _dal.getallcounty(); if (groupserviceid == "") { groupserviceid = null; } if (subjectid == "") { subjectid = null; } if (typeserviceid == "") { typeserviceid = null; } if (stateid == "") { stateid = null; } if (countyid == "") { countyid = null; } viewbag.groupserviceid = groupserviceid; viewbag.subjectid = subjectid; viewbag.typeserviceid = typeserviceid; viewbag.stateid = stateid; viewbag.countyid = countyid; viewbag.ocasion = ocasion; var advertisements = _dal.filter(page, groupserviceid, subjectid, typeserviceid, stateid, countyid, ocasion, searchbox); if (advertisements == null) return httpnotfound(); return request.isajaxrequest() ? (actionresult) partialview("_advertisementlist", advertisements) : view(advertisements); }
this exception
mountvol x: /s copy %windir%\system32\secconfig.efi x:\efi\microsoft\boot\secconfig.efi /y bcdedit /create {0cb3b571-2f2e-4343-a879-d86a476d7215} /d "debugtool" /application osloader bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} path "\efi\microsoft\boot\secconfig.efi" bcdedit /set {bootmgr} bootsequence {0cb3b571-2f2e-4343-a879-d86a476d7215} bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} loadoptions disable-lsa-iso,disable-vbs bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} device partition=x: mountvol x: /d system.argumentoutofrangeexception occurred hresult=0x80131502 message=index out of range. must non-negative , less size of collection. source=mscorlib stacktrace: @ system.throwhelper.throwargumentoutofrangeexception(exceptionargument argument, exceptionresource resource) @ system.collections.generic.list`1.get_item(int32 index) @ asp._page_views_advertisements__advertisementlist_cshtml.execute() in c:\users\ipa3\documents\visual studio 2017\projects\meydanmvc\meydanmvc\views\advertisements\_advertisementlist.cshtml:line 109 @ system.web.webpages.webpagebase.executepagehierarchy() @ system.web.mvc.webviewpage.executepagehierarchy() @ system.web.webpages.webpagebase.executepagehierarchy(webpagecontext pagecontext, textwriter writer, webpagerenderingbase startpage) @ system.web.mvc.razorview.renderview(viewcontext viewcontext, textwriter writer, object instance) @ system.web.mvc.buildmanagercompiledview.render(viewcontext viewcontext, textwriter writer) @ system.web.mvc.htmlhelper.renderpartialinternal(string partialviewname, viewdatadictionary viewdata, object model, textwriter writer, viewenginecollection viewenginecollection) @ system.web.mvc.html.partialextensions.partial(htmlhelper htmlhelper, string partialviewname, object model, viewdatadictionary viewdata) @ system.web.mvc.html.partialextensions.partial(htmlhelper htmlhelper, string partialviewname, object model) @ asp._page_views_advertisements_index_cshtml.execute() in c:\users\ipa3\documents\visual studio 2017\projects\meydanmvc\meydanmvc\views\advertisements\index.cshtml:line 93 @ system.web.webpages.webpagebase.executepagehierarchy() @ system.web.mvc.webviewpage.executepagehierarchy() @ system.web.webpages.startpage.runpage() @ system.web.webpages.startpage.executepagehierarchy() @ system.web.webpages.webpagebase.executepagehierarchy(webpagecontext pagecontext, textwriter writer, webpagerenderingbase startpage) @ system.web.mvc.razorview.renderview(viewcontext viewcontext, textwriter writer, object instance) @ system.web.mvc.buildmanagercompiledview.render(viewcontext viewcontext, textwriter writer) @ system.web.mvc.viewresultbase.executeresult(controllercontext context) @ system.web.mvc.controlleractioninvoker.invokeactionresult(controllercontext controllercontext, actionresult actionresult) @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult) @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)
Comments
Post a Comment