Click here to Skip to main content
15,036,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

i am new to MVC,

i am using two partial view s for two user controls let it be first and second, actually it should fetch the data from the user controls through that URL depending upon the query string.
problem is while i run the page, both first and second partial view displaying same value(exactly what first one shows)


@Html.Partial("~/Views/Shared/_first.vbhtml") it will refer the .ascx file's url

@Html.Partial("~/Views/Shared/_second.vbhtml")

so give me a solution please, if you need more , sure i will

thanks in advance

Velsamy A
Posted

1 solution

1.In MVC you can use more partial views in the same view.

2.The data shown in the partial view should depend only on the Model that are used by the partial view. The partial view use the data from its Model and show some (or all) of them in their content.

3.In order to give you more advises you should give more details about what do you want to do and also about your code in your question above!
   
v2
Comments
avelsamy 2-Apr-14 8:56am
   
yeah of course , i have fetched the values using datatable in model,

then i assigned the to the object as select list, after that the select list is assigned to the partial views listbox id, problem is first view is working fine.... but the second one didnt display anything


its shows an error - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'Listboxid'.
Raul Iloc 3-Apr-14 1:03am
   
You should show me some code from your 2nd view in order to can give more advises. Also the code from the parent of your partial view.
Raul Iloc 3-Apr-14 3:41am
   
The error is generating by the fact that you are not providing the right parameters to the next call "@Html.ListBox(...)". In your controller your property "model.lstTrxn" must be created as a list of "SelectListItem" objects!
avelsamy 3-Apr-14 4:53am
   
i got it Raul.... thank you....


avelsamy 3-Apr-14 4:54am
   
One more question ,

Hi Friends,

I am new to MVC,

I should manage three DropDownListBoxes in my single view page , let it be

Scheme_category<pre lang="xml"><DDL1></pre>
<pre lang="xml">
<scheme_item 1="">
<scheme_item 2="">
......
<scheme_item n=""></pre>



Fund_category <pre lang="xml"><DDL2></pre>
<pre lang="xml">
<fund_item 1="">
<fund_item 2="">
......
<fund_item n=""></pre>



Payment_Category<pre lang="xml"><DDL3></pre>

<pre lang="xml">
<payment_item 1="">
<payment_item 2="">
......
<payment_item n=""></pre>


1. If i click anyone of the Scheme_item from DDL1 means, DDl2 and DDL3 should load their related category items by automatically depending upon the condition of DDL1 (It means Postback should be done in there itself)

(or else)

If I click anyone of the DDL's item, other two DDLs should Load their items ,automatically depending upon the conditions


2. after that i have to submit the page through the button_click(postback will be done here)


my Question is : Multiple Postbacks should be done , but different controls like( DDL1,DDL2,DDL3 and BUTTON

How can i handle the multiple postbacks in same view page, help me




note: three DropDownList Boxes and button are placed in Same view page.

Thanks In Advance,

Velsamy A
Raul Iloc 3-Apr-14 6:37am
   
You should use Javascript (jQuery) to invoke AJAX calls to the controller that in response will send you back only the partial view with the new filled drop down list for your current context.
avelsamy 3-Apr-14 7:25am
   
but if we are use javascript to invoke Ajax means, suppose javascript disabled in that browser means No Use know....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900