Opinion: Best Way To Retrieve/list Data Using .net Mvc
Jul 21, 2010
I'm new with the MVC framework and I was wondering what you think is the ideal way to retrieve data and list it on a page. Specifically, I'm referring to data used in report type pages, not lists of movies, books, or other clear 'objects'.
Most online samples seem to suggest using ADO.net Entity Data Models & LINQ which are automatically built by the wizard using the DB schema - and that seems great for things like movies/books, but doesn't seem so intuitively 'correct' for random data needed for a report.
Update:To be more specific, I basically need to take a set of rows from a Sql server view and display them on a page. Some of it just in a list, and some in graphs (planning to use the .net charting control). I realize what I'm doing is very simple, I'm just not sure what the best way of doing it using the MVC framework is. Hope that clears it up a bit...
View 3 Replies
Similar Messages:
Feb 17, 2011
I was comparing SharpArch to Spring.NET earlier, and had some thoughts.Both contain Core, Data and Web namespaces (as well as others). While SharpArch maintains them all in one assembly, Spring.NET does so in separate assemblies.Initially, I liked this concept, because one could reference the Core without indirectly referencing something they didn't need, like System.Web.However, it later occurred to me that whether or not things were combined, they still operated within the .NET space and have equal access to the GAC.So why not put things in one assembly, as long as individual elements in their namespaces do not make use of certain things?Of course, I'm talking about a base-line assembly, not an actual business solution.
View 1 Replies
Apr 13, 2010
i did not know how to phrase the question above but this is what I want to achieve;
using a linq to sql datacontext db, I want to retrieve a sequence of items with the code below [Code]....
View 3 Replies
Jan 19, 2010
Here is my page:
[Code]....
It basically is 4 questions with each answer assigned a value.
What I would like to do is when the button is clicked the selected values are retrieved and calculated to give a total.
That total is then compared against some common totals and the next value is shown.
So is the total is 8= Very Good, 6= Very Bad, 4= Terrible etc.
The two labels Result and Truth would sho the numerical result and the truth according to the scale.
I am at a loss on how to retrieve the list button clicked value, how to add them up and referance that to the Truth result.
its complicated (to me its "bang head against wall" difficult.
View 17 Replies
Mar 29, 2011
I have a list which is defined as List<SoftwareTitles> softwareTitlesList = new List<SoftwareTitles>();
and the SoftwareTitles is a class which is defines as follows:
public class SoftwareTitles
{
string softwareTitle;
string invoiceNumber;[code]....
And now I'm adding the values from the sql server database to the list defines as follows:
public List<SoftwareTitles> SoftwareListRetrieve()
{
ConnectionToSql con1 = new ConnectionToSql();
string connectionString = con1.ConnectionStringMethod();[code]....
I want to find out the software title for every occurence of invoice number by looping through List<>. And I don't know how ? I have tried to loop through the List<> by the following code. I wanted to use something like contains i.e., softwareTitlesList[i].contains but seems like there is no such property or method
for(int i=0; i<softwareTitlesList.Count;i++)
{
softwareTitlesList[i].
View 1 Replies
Mar 15, 2010
I have two tables related to a number (ie, persons with Firefox), I should retrieve data from a View where he imposed the following code:
[Code]....
When I go to send the following to view controller via Post did not recover the data, the controller parameter dell'actin as I pass him the Person object p.Qualcuno potrebe me explain why I get the results and those of the Person objectcomponents, I do not return?
View 11 Replies
Jul 14, 2010
I have some labels on my Page (e.g. Label1...Label100).
I don't want to loop through all Labels to check if Text property is = "" (or string.Empty, whatever), so this's my question - is it possible to use LINQ or Lambda Expression to get all "empty" labels ?
View 3 Replies
Feb 17, 2011
I am developing a twitter-like application and I want to retrieve friends friend list using my asp.net web application. How can I do that?
View 2 Replies
Sep 24, 2010
I have an application that sends mails with Gmail SMTP server (smtp.gmail.com) using SSL.
Now I want to read the emails from that account, does anyone have how can I make this programatically in C# and ASP.NET?
At this point I'm using this code:
[Code].....
And when I debug it it's shows that it's connected but no response in retrieving emails.
View 3 Replies
May 6, 2010
Some ids are pulled out from the XML field of a certain User Profile . Those ids have their text values stored in a SQL table.
What is the best way to map that xml list to the SQL table in order to populate a dropdown list which contains ids from the XML list and text values from the SQL table?
View 1 Replies
May 15, 2010
the dropdown list is showing data from database, but how to retrieve the selected value and store it in a session variable??
View 1 Replies
Mar 26, 2011
look this code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sql = "select date from news_events";[code]....
Which Get method should i use to retrieve date from the column to dropdown list"ddl_month". Is above method correct or suggest me another one below is the error associated with above code..
Error Argument '1': cannot convert from 'System.DateTime' to 'string'
View 4 Replies
May 6, 2010
I am utilizing local security groups to secure my application and I need to list all the available groups on the local machine. I can get the list of groups a user is a member of, but I need the complete list of available groups.
View 1 Replies
Jun 24, 2010
I have drop down list box that I would like to show two columns, is this possible? Or can it be done with a list box?The query correctly retrieves all of the table data to be displayed, one colum is an abbreviation, the other a bit longer description.
View 2 Replies
May 27, 2010
I have a situation where I want to show the selected records out of total records for a product of an employee
1) There is a checkbox list bind to <List> of objects from object datasource (For total items in list)
2) Now I want to check the selected items for a particular record in this list
3) For this purpose I have another list of <List> selected items returned by data access layer (For selected items for that employee )
4) How do I bind the selected objects with the total items list ?
5) In spaghetti coding model it was all too easy just by binding the checkbox list with a sql data source and running a for each on form load
View 5 Replies
Jan 17, 2011
I have a databound dropdownlist and have a problem with the default value it selects.When I attempt to edit a record the dropdownlist shows the first value in the list rather than the current value. I want the dropdown list to display the current value.
I'm sure this is very simple but I'm very new to ASP.NET.
I'm using .NET version 4.
View 4 Replies
Oct 21, 2010
1 My DataTable Return following Data
Acct Books Annual
Acct Books Monthly
Acct Tax Income Tax
Admin GH Eqpt
Admin Offc Eqpt
Admin Offc Misc
Admin Offc Eqpt
[code]...
View 10 Replies
Dec 1, 2010
How would I create a list then on click add data to the list which is then stored into a session variable, then on another page retrieve the variable and output them? Currently I have:
Page Load:
List <myClass> listName=new List<myClass>
OnClick:
listName.add(3);
listName.add(4);
Session["IDs"]=listName;
Second Page
I need to get the whole list and add output the list so I can output (hopefully) the '3' and '4'.
View 1 Replies
Sep 29, 2010
The List Page display child Entity using the gridview each row will have link to the parent
How can I change the link so it shows the parent but in list view(using list.aspx) not detailes (detailes.aspx)view
View 1 Replies
Jan 12, 2011
I have customer data in MSSQL database. More than 1million records i have. I want to select a random 2000 records
from the one million record and do some manipulation. After manipulating the data i want to store that data to some other database.
How to achive it in c# and MSSQL2008?
View 3 Replies
Aug 4, 2010
i have dataset with two data tables inside
dt1
dt2
i want to bind data from both data table t gridview
for this how can i make join between two data tables inside dataset and retreive data
View 3 Replies
Oct 10, 2010
I am stuck at this point "Displaying a dropdown list of Categories with a --None -- Option. I want the gridview control to display 2 dropdown list one in read-only mode and the other in edit mode. When a record is in read-only mode, the dropdownlist's enabled property will be set to false."When it's on a read-only mode, it doesn't display the selected Category. it shows but the "No Category". When i click on edit to edit or change category, it doesn't display the selected category.
The example is given below( I am reading the book Sams Teach yourself ASP.NET 2.0 by Scott Mitchell. page 628)
<asp:Label ID="UserIdValue" runat="server" Visible="False"></asp:Label>
<asp:SqlDataSource ID="picturesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Pictures] WHERE ([UserId] = @UserId) ORDER BY [UploadedOn] DESC"
DeleteCommand="DELETE FROM [Pictures] WHERE [PictureID] = @PictureID"
InsertCommand="INSERT INTO [Pictures] ([UserId], [CategoryID], [Title], [Description], [UploadedOn]) VALUES (@UserId, @CategoryID, @Title, @Description, @UploadedOn)"
UpdateCommand="UPDATE [Pictures] SET [UserId] = @UserId, [CategoryID] = @CategoryID, [Title] = @Title, [Description] = @Description, [UploadedOn] = @UploadedOn WHERE [PictureID] = @PictureID">
<DeleteParameters>
<asp:Parameter Name="PictureID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="UserId" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text"/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="UserId"/>
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
<asp:Parameter Name="PictureID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="categoriesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId)">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="maxPictureIDDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX(PictureID)
FROM Pictures
WHERE UserId = @UserId">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="cannotUploadImageMessage" runat="server"
Text="The photo could not be added to your album either because you did not specify a file to upload or the file specified was not a JPEG image with the file extension .JPG"></asp:Label>
<br />
<asp:DetailsView ID="dvPictureInsert" runat="server"
DataSourceID="PicturesDataSource" Height="50px" Width="125px"
AutoGenerateRows="False" CellPadding="4" DataKeyNames="PictureID"
DefaultMode="Insert" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<Fields>
<asp:TemplateField HeaderText="Picture">
<InsertItemTemplate>
<asp:FileUpload ID="imageUpload" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="imageUpload" Display="Dynamic"
ErrorMessage="There was no file selected" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="pictureCategory" DataSourceID="categoriesDataSource"
runat="server" DataTextField="Name" DataValueField="CategoryID"
SelectedValue='<%# Bind("CategoryID") %>'
Visible='<%# Bind("CategoryID") %>' AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="">-- Select Category --</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="you must provide a name for the title"
ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'
View 2 Replies
Oct 26, 2010
I need to develop a page in my applicaiton like the image for the user lists.
I need to get the list of users under a group and need to show likw this.
View 4 Replies
Oct 8, 2010
I am playing about just now trying to teach myself a little bit about the entity framework. I have a Gridview data bound to a Entity Date Source using the Entity Framework. If I select certain items in that list I then wish to redirect another page and populate another gridview with just the items selected (but with more detail, different includes/navigation properties)
This is probably the most simple thing but I have spent 2 hours banging my head on the wall trying to get this to work. Essentially I have a continue button which when clicked should identify all the UIDs (a column in the gridview) of the rows and allow me to subset to just these rows and pass them to another page to be rebound to another datagrid
View 2 Replies
Mar 16, 2010
i am still stumped with this operation: i am trying to retrieve a GridView selected row data..here is my code.. the commented part that gives me the selectedindex works just fine....but the one giving the selected row cell value does't work and there is no error.. The update operation is done successfully...weired. i need to assigned selected row cells values to variables ..do some calculations and then re-assign the result calculation to cell[9]..
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string s = GridView1.SelectedRow.Cells[5].Text;
TextBox1.Text = s.ToString();
//string s2 = GridView1.SelectedIndex.ToString();
//TextBox1.Text = s2.ToString();
}
View 5 Replies