MVC :: Understanding With Searchresults And Dropdown Filters In The Same View

Jun 22, 2010

I am new to ASP.NET MVC 2 and I am having a very hard time figuring out how to do even the most simple things. I have a couple of books on ASP.NET MVC as reference but I cannot find any answer to my question. Here is what I basicalyl have and need:

I am trying to create a page that shows me a table that contains some Product Statistics with columns such as Date, ProductCount, PriceCount. On the same page I want to add some filters such as "Product category" (dropdown) and a date from and date to (jquery ui datepicker). When a user clicks on "Filter" it should reload the page and in the Product Statistics it should show the statistics filtered by "Product Category" and the date range. At the same time I want to make sure that the selected Product Category from the dropdown list does not get lost, the same for the date pickers.

I have a GlobalReportController with two actions: "Index" and "Filter". I have also a GlobalReportIndexViewModel and a ReportFilter. In the "Index" action, I retrieve the complete list of statistics and product categories and fill up the ProductStatisticsIndexViewModel.

I am having a whole lot of problems trying to grasp how the ASP.NET MVC paradigm works exactly.

View 8 Replies


Similar Messages:

Forms Data Controls :: Multiple Dropdown Filters To Sort A Grid View

Jan 4, 2010

wondering if someone can possibly help me out with a gridview. I have data coming into a grid and I know how to filter the data using one dropdown, I'm trying to get a little more advanced now. I'd like to filter using three dropdowns.

This is what I have so far: I don't know how to hook the downlists to the query?

<asp:DropDownList runat="server" id="DropDownList1" Width="90px">
<asp:ListItem Value="item_num">Item #</asp:ListItem>
<asp:ListItem Value="lot_num">Lot #</asp:ListItem>
<asp:ListItem Value="production_code">Production Code
</asp:ListItem>
<asp:ListItem Value="batchcode">Batch Code</asp:ListItem>
<asp:ListItem Value="inbound_no">Inbound #</asp:ListItem>
<asp:ListItem Value="recv_date">Received Date</asp:ListItem>
<asp:ListItem Value="location">Location</asp:ListItem>
<asp:ListItem Value="category">Category</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList runat="server" id="DropDownList2" Width="160px">
<asp:ListItem Value="=">is equal to</asp:ListItem>
<asp:ListItem Value="<=">is less than or equal to
</asp:ListItem>
<asp:ListItem Value=">=">is greater than or equal to
</asp:ListItem>
<asp:ListItem Value="<>">is not equal to</asp:ListItem>
<asp:ListItem Value="begins with">Begins With</asp:ListItem>
<asp:ListItem Value="Like">Ends With</asp:ListItem>
</asp:DropDownList>
<asp:TextBox runat="server" id="TextBox1" Width="150px">
</asp:TextBox>
<asp:Button runat="server" Text="Go" id="Button8" BackColor="Lime" />
<asp:Button runat="server" Text="Clear Filter" id="Button9" /><br />
<input name="Checkbox1" type="checkbox" /><label id="Label5">
Include Items containing "Zero on Hand" Quantity.<br />
Group by Fields: <input name="Checkbox2" type="checkbox" />
Item/Lot
<input name="Checkbox3" type="checkbox" /> Production Code
<input name="Checkbox4" type="checkbox" /> Batch Code</label><label id="Label4"></label><br />
<hr />
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Font-Size="Small" BorderStyle="None" BackColor="White" GridLines="Vertical" BorderColor="#999999" BorderWidth="1px" CellPadding="3" Font-Underline="False"
AllowSorting="True" AllowPaging="True" PageSize="20">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:boundfield DataField="STATUS" HeaderText="Status" SortExpression="STATUS">
</asp:boundfield>
<asp:boundfield DataField="ITEM_NUM" HeaderText="Item #" SortExpression="ITEM_NUM">
</asp:boundfield>
<asp:boundfield DataField="LOT_NUM" HeaderText="Lot #" SortExpression="LOT_NUM">
</asp:boundfield>
<asp:boundfield DataField="LOT_EXT" HeaderText="Lot Ext" SortExpression="LOT_EXT">
</asp:boundfield>
<asp:boundfield DataField="RECV_DATE" HeaderText="Recv Dt" SortExpression="RECV_DATE">
</asp:boundfield>
<asp:boundfield DataField="PRODUCTION_CODE" HeaderText="Prod Code" SortExpression="PRODUCTION_CODE">
</asp:boundfield>
<asp:boundfield DataField="QTY_ONHAND" DataFormatString="{0:NO}" HeaderText="OnHand" SortExpression="QTY_ONHAND">
</asp:boundfield>
<asp:boundfield DataField="QTY_RESERV" HeaderText="Reserv" SortExpression="QTY_RESERV">
</asp:boundfield>
<asp:boundfield DataField="QTY_AVAIL" DataFormatString="{0:N}" HeaderText="Avail" SortExpression="QTY_AVAIL">
</asp:boundfield>
<asp:boundfield DataField="QTY_ADJUST" HeaderText="Adjust" SortExpression="QTY_ADJUST">
</asp:boundfield>
<asp:boundfield DataField="QTY_SHIP" HeaderText="Shipped" SortExpression="QTY_SHIP">
</asp:boundfield>
<asp:boundfield DataField="QTY_RECV" HeaderText="Recv" SortExpression="QTY_RECV">
</asp:boundfield>
<asp:boundfield DataField="PROD_DATE" HeaderText="Prod Date" SortExpression="PROD_DATE">
</asp:boundfield>
<asp:boundfield DataField="RELEASE_DATE" HeaderText="Release" SortExpression="RELEASE_DATE">
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" ForeColor="White" Font-Bold="True" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:RemoteRooster %>" SelectCommand="SELECT * FROM [INVENTRY] WHERE OWNER = 'CompanyName' AND QTY_ONHAND > '0'">
</asp:SqlDataSource>

View 8 Replies

Forms Data Controls :: Filters To A Gridview Control Like Filters In Excel Sheet?

May 26, 2010

How to apply filters to a gridview control like filters in excel sheet?

View 2 Replies

Grid View Filters / How To Set Filter Two Or More Than Two Columns

Feb 21, 2011

Am running asp.net application with gridview.Am using filters to filter only one column.Now i want to filter two or more than two columns.How to i set the filters for that..if i give && or|| operators it is showing syntax error..

i given the code as;
"
ProviderName="<%$ ConnectionStrings:booksConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [book]"
FilterExpression="UserName Like '{0}%' || Password Like '{0}%'" >

View 1 Replies

MVC :: Passing Dropdown Value From Partial View To View (parent)?

Jan 10, 2011

I have a partial view that has only a dropdown, i have called this partial view from a view. I can able to pass the model to this partial view and it renders successfully. However when some user selects a particular text from the dropdown, the corresponding value should be passed to view and it should be displayed in the label in view.

View 7 Replies

.NET: Understanding Web.config In .net?

Apr 12, 2010

For example, i am using forms authentication... and i notice there is a system.web and then it closed /system.web and then below configuration there are additional location tags.here is an example, if you ntoice there is an authentication mode=forms with authorization i presume this is the ROOT....... It is also self contained within a system.web .... Below this there are more location= with system.web tags....I have never really understand what i am actually doing.. I have tried checkign the MSDN documentation but still i don't fully understand up....

If you notice with my example.... everything is stored in 1 web.config... i thought the standard waas create a standard web.config and then create another web.config in the directory where i wish to protect it..???

<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />[code]....

View 3 Replies

Understanding Syntax In C#?

Apr 23, 2010

understand what is going on in the code line below:

Table t = (Table)Page.FindControl("Panel1").FindControl("tbl");
I understand Page.FindControl("Panel1").FindControl("tbl");
Why is there a (Table) before the Page.FindControl?

View 4 Replies

Understanding Of SQL Statements?

Jan 3, 2011

string sqlstring =
"SELECT DISTINCT STAFF_ID, SCHOOL_CODE FROM MODULE_TIMETABLE_STAFF WHERE STAFF_ID != '" +userId +
"' AND STAFF_ID LIKE '%" + Searcht +
"%' ORDER BY STAFF_ID ASC";

can anyone explain this statement for me? especiallythese signs !=,+ +

View 4 Replies

Understanding Asp.Net MVC Framework?

Feb 9, 2011

i am new to MVC and i want to learn it. Please advise me some good material for understanding Asp.Net MVC framework.

View 1 Replies

MVC :: Understanding Binding A Field Value?

Jul 26, 2010

I am trying to make a master - detail form with mvc.

I use ajax tab control for this.

I use MvcContrib.UI.Grid.

[URL]

View 6 Replies

C# - Understanding .resx Variables?

Jun 30, 2010

I am working on a project for my company, and while tracing previously written code I came upon this:

<value>A payment authorization for {0:C} has been received.</value>

What does {0:C} mean? I have been trying to find out and am having no luck.

View 2 Replies

Understanding Special Symbols In .aspx?

Jun 24, 2010

Special symbols are a real pain to learn about because you can't Google for them (try doing a Google search for "<%#" and you's get nothing).

I've been a programmer for many years, and I'm trying to get my head around ASP.net, and especially the "special symbols"; what they mean, where to find out more information about them. Because they're impossible to search for, it'd be wonderful if there were special resources in place to help newbies learn about these.

Specifically, I'm looking for detailed instructions on the porpose for, and use, of the following constructs:

<%@ %>
<%$ %>
<%# %>
<%= %>

What is expected in each, what is allowable in each, and what "gotchas" would a newbie have to be careful for when employing each.

For example, I want to do some coding in a <%# %> block, like:

Text="<%# if (Eval("InUse")) {Eval("ProductName")} else {"Not In Use"} %>"
-- would this be allowable, and if not, what are reasonable alternatives?

View 1 Replies

MVC :: Update A Dropdown List In 2 RC 2 View

Mar 9, 2010

I was trying to implement a dynamic update of a dropdown list in an ASP.NET.MVC2 RC 2 view. My code didn't work. So, in order to verify my approach, I resorted to a published code, which supposedly should be correct: In the View:

<%= Html.DropDownList("Numbers",(IEnumerable<SelectListItem>)ViewData["Services"]) %>
<select id="Select1">
</select>
<input type="button" id="Button1" value="Fill By Array" />
<script language="javascript" type="text/javascript">
$(function() {
$("#Button1").click(function(e) {
e.preventDefault();
var data = [];
$.getJSON("/Home/GetListViaJson", null, function(data) {
data = $.map(data, function(item, a) {
return "<option value=" + item.Value + ">" + item.Text + "</option>";
});
$("#Select1").html(data.join(""));
});
});
});
</script>
In the Controller:
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
//ViewData["Message"] = "Welcome to ASP.NET MVC!";
ViewData["Numbers"] = GenerateNumbers();
return View("Index");
}
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetListViaJson()
{
return Json(GenerateNumbers());
}
private static List<SelectListItem> GenerateNumbers()
{
var numbers = (from p in Enumerable.Range(0, 20)
select new SelectListItem
{
Text = p.ToString(),
Value = p.ToString()
});
return numbers.ToList();
}
public ActionResult About()
{
return View();
}
}

The Html.DropDownList was correctly populated on PageLoad() event. But the GetListViaJson() action method, when called on the button event, did not update the "Select1" element. how to solve this update problem.

View 7 Replies

Web Forms :: Sorting And Understanding Web Page Errors?

Sep 14, 2010

your posts and answers are very informative and helpful in my own devolopment and understanding the nature of the beast. Im running vs2010 on a 64bit windows 7 devolopment machine. For days I have been trying to get a Microsoft Reportview to render in a popup. ( i have done this in vs2008 ). I have tried applying the same code from vs2008 to Vs2010, but am comming up with page erros. When loading the default.aspx ( testpage ) I get 'Done but with errors'. If I click on button 1 which shows the popup, I get the report viewer, but it just sits there 'loading'. From advice givenm on this forum, I have used the IE view source code to try and loacate the problem... but to be honest, I dont understand why the page complies ok, but i get errors when it is run, or indeed how to rectify the problem. I have highlighted the two errors.Ie view source code:

[Code]....

[Code]....

[Code]....

View 1 Replies

C# - Understanding Regular Expression For Number Range

Jan 26, 2011

I'm trying to build up some regular expressions to validate some textbox controls. I have done some research and testing but cannot get this one working. Examples of what i am trying to create regular expressions for are as follows:

Range 0-45, 0 decimal places
Range 0-20, 2 decimal places
Range 16-65, 0 decimal places
Range 0-99, 2 decimal places
Range 0-1500000, 0 decimal places
Range 0-200, 1 decimal place

For 1 and 5 respectively, I have used

([0-9]|[0-9]d|45)$
([0-9]|[0-9]d|1500000)$

The first one I am having problems for is an age range of 16-65 (inclusive), where I want no decimal places. After a post on here (Regular expression to allow numbers between -90.0 and +90.0) I thought I could use the logic and get it sussed, but can't! The expression I got to was:

(d|([1-6][6-4]))|65

View 2 Replies

MVC :: Understanding The Normal Flow Between Multiple Controllers (1.0)?

Sep 8, 2010

I am building a medium to large application with ASP.NET MVC 1.0 (we'll upgrade to the latest after we meet some schedule commitments). The application contains a number of workflows, with a separate controller for each workflow, and the home controller owning the main page of the application. So, I end up with the home page, on which the user makes selections and then clicks one of a number of action buttons to proceed down a given workflow. For a given workflow, I seem to have the following flow between controllers:

homeController (home view) --> action-button --> workflowController --> homeController (completion view)

I figure the action-button does a post to the home controller, which the selections the user made are saved to session state in the appropriate model. The workflowController will handle things as the user moves through one or more views specific to the workflow, but then things end on a common completion page.My question(s):1 - Is this a reasonable way to break up responsibilities amoung multiple controllers?2 - How do I actual accomplish the hand-off to the workflow specific controller? I'd really like to avoid a redirect and the attendent round trip to the browser since controller structure is really an internal implementation issue and shouldn't impose a performance penalty on the user.3 - Is it possible to pass a model from the originating controller to the destination controller, or do I have to exclusively depend on persistent state to pass things to the "next" controller?

View 1 Replies

MVC :: Dropdown Parameter In View For Reports Are Not Working?

Apr 13, 2010

I have a report where I need to select parameter values from dropdowns. Reports works fine when I run it on reportserver manager or when I do RUN.

The problem is when I try opening it in the MVC views to select parameters from a dropdown, its subsequent dropdown is not able to show its values

for example:

I am able to select first DD Country as it does not have any thing to select earlier.

The State DD is not rendering its relavent states from selected country. (it works in report manager and when I run it without debugging)

Question: how do code to make the dropdowns working.

View 1 Replies

State Management :: Understanding ViewState And Hidden Fields?

Aug 8, 2010

If I create a new project, start this project and look at the source code, I see that there are some additions to the original code. The first this, what is "ViewState" and what does the hash mean? Why is the input control hidden?Here an example:

[code]....

View 3 Replies

State Management :: Understanding The ViewState Lifecycle On An ASP.NET Form?

Aug 5, 2010

I have an ajax form that has a simple click event. Inside the click event, at the end of the method, I have a Response.Redirect back to the same page. For the purpose of this thread, I will leave out the reasoning of this (it is just something that I had to do). Once the ajax call is complete and the redirect takes place, all of my default control viewstates get wiped out. The thing that doesn't make sense, is that if I define my own ViewState right before the Response.Redirect, these ViewStates also get wipedout. So, my question is, do ViewStates only hold their values after one postback/refresh? And, is there a way to use ViewState with the method described above? I am being forced to use the querystring to pass parameters.

View 2 Replies

Web Forms :: Understanding App_Code Related Error CS0121?

Nov 9, 2010

I've searched for about a day and a half and have not been able to find an explanation that I can understand, so please forgive me if this is something you have seen/answered before.

I have a web site that uses the App_Code folder. There are several CS files and classes in that folder. All of this works fine up to this point. However, I wrote an extension method with its own class and file. This fails with the following ambigous reference error (the app is in C#):

Compiler Error Message: CS0121: The call is ambiguous between the following methods or properties: 'GSGeneral.ExtensionMethods.IsNumeric(string)' and ''GSGeneral.ExtensionMethods.IsNumeric(string)'

If I change the extension to a plain static class, there are no problems with it. Based on that, it seems like this is related to it being an extension method.Now I know a work around is to move the file out of the App_Code folder - I've tried it and it works. My question is why does this have issues when all of the other items in the App_Code folder do not.

View 9 Replies

MVC :: Create A View Which Should Show The Build Documents And A Dropdown?

Dec 8, 2010

I have a document which may have many revisions. I need to create a view which should show the build documents and a dropdown which shows different revisions of the build document. For eg. I have a document Doc1 which have 4 revisions. So the view should show the Doc1 and a dropdown which have options 1 to 4. The will contain a table of document name and the dropdowns. How can I create the dropdown dynamically?

View 2 Replies

GridView In Webpart With Multiple Filters?

Apr 12, 2010

I'm currently working on a highly configurable Database Viewer webpart for WSS 3.0 which we are going to need for several customized sharepoint sites. but i fear it's necessary to recap the whole issue. As background information and to describe my problem as good as possible, I'll start by telling you what the webpart shall do:

Basically the webpart contains an UpdatePanel, which contains a GridView and an SqlDataSource. The select-query the Datasource uses can be set via webbrowseable properties or received from a consumer method from another webpart. Now i wanted to add a filtering feature to the webpart, so i want a dropdownlist in the headerrow for each column that should be filterable. As the select-query is completely dynamic and i don't know at design time which columns shall be filterable, i decided to add a webbrowseable property to contain an xml-formed string with filter information.

So i added the following into OnRowCreated of the gridview:

void gridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].GetType() == typeof(DataControlFieldHeaderCell))
{
string headerText = ((DataControlFieldHeaderCell)e.Row.Cells[i]).ContainingField.HeaderText;
// add sorting functionality
if (_allowSorting && !String.IsNullOrEmpty(headerText))
{
Label l = new Label();
l.Text = headerText;
l.ForeColor = Color.Blue;
l.Font.Bold = true;
l.ID = "Header" + i;
l.Attributes["title"] = "Sort by " + headerText;
l.Attributes["onmouseover"] = "this.style.cursor = 'pointer'; this.style.color = 'red'";
l.Attributes["onmouseout"] = "this.style.color = 'blue'";
l.Attributes["onclick"] = "__doPostBack('" + panel.UniqueID + "','SortBy$" + headerText + "');";
e.Row.Cells[i].Controls.Add(l);
}
// check if this column shall be filterable
if (!String.IsNullOrEmpty(filterXmlData))
{
XmlNode columnNode = GetColumnNode(headerText);
if (columnNode != null)
{
string dataValueField = columnNode.Attributes["DataValueField"] == null ? "" : columnNode.Attributes["DataValueField"].Value;
string filterQuery = columnNode.Attributes["FilterQuery"] == null ? "" : columnNode.Attributes["FilterQuery"].Value;
if (!String.IsNullOrEmpty(dataValueField) && !String.IsNullOrEmpty(filterQuery))
{
SqlDataSource ds = new SqlDataSource(_conStr, filterQuery);
DropDownList cbx = new DropDownList();
cbx.ID = "FilterCbx" + i;
cbx.Attributes["onchange"] = "__doPostBack('" + panel.UniqueID + "','SelectionChange$" + headerText + "$' + this.options[this.selectedIndex].value);";
cbx.Width = 150;
cbx.DataValueField = dataValueField;
cbx.DataSource = ds;
cbx.DataBound += new EventHandler(cbx_DataBound);
cbx.PreRender += new EventHandler(cbx_PreRender);
cbx.DataBind();
e.Row.Cells[i].Controls.Add(cbx);
}
}
}
}
}
}
}

GetColumnNode() checks in the filter property, if there is a node for the current column, which contains information about the Field the DropDownList should bind to, and the query for filling in the items.

In cbx_PreRender() i check ViewState and select an item in case of a postback. In cbx_DataBound() i just add tooltips to the list items as the dropdownlist has a fixed width.

Previously, I used AutoPostback and SelectedIndexChanged of the DDL to filter the grid, but to my disappointment it was not always fired. Now i check __EVENTTARGET and __EVENTARGUMENT in OnLoad and call a function when the postback event was due to a selection change in a DDL:

[Code]....

When i have two or more filters set which return zero rows, and i change back one filter to something that should return rows, the gridview remains empty (although the pager is rendered). I have to completly refresh the page to reset the filters. When debugging, i can see in the overridden CreateChildControls of the grid, that the base method indeed returns > 0, but anyway.the gridView.RowCount remains 0 after databinding. Anyone have an idea what's going wrong here?

View 1 Replies

How To Retain The Values Of The Filters And Its Result Using C#

Mar 17, 2010

Question:-

Page is a typical search page with few filters on it. When search for records based on filters, it shows result in Gridview. From grid view records, user can click on any record to see the details which takes the focus on new page. Its working fine so far.Now when user comes back from details page to search page. I am loosing selected filters values and no result in grid view.How can i display selected filters and its results in gridview when user is coming back on search page? Any example etc.?

View 2 Replies

Access :: Create A Query From Filters?

Jan 25, 2011

am a bit unsure of the best way to go about this. I have a form where data is entered, date ranges, usernames, passwords etc and when the button is pressed on the form it searches a database and returns values which match the values entered.I can't think of the most efficient way to do this, could anyone give some pointers on where to start?I thought perhaps of writing a query and then just putting in the variables which pick up the entered values and reading it all in as one big string something like:

SELECT * FROM DB WHERE ProductID = "DateTxtBox" & "NameTxtBox"

I haven't checked the syntax but this is just to give you a idea of what I am thinking.

View 5 Replies

MVC3 Make Possible To Use IOC With Action Filters?

Aug 22, 2010

Will MVC3 make possible to use IOC with Action Filters? Is this on the roadmap?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved