.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Creating class in controller

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
I am using vs 2010, mvc, linq to sqlMy Model is .dbml filetbl_teacher,tbl_class,tbl_subject etc are involvedI write code in my controller for table join.public ActionResult Index() { var DataContext = new SMSAPPDataContext(); var result= from t in DataContext.tbl_teachers from e in DataContext.tbl_teacherenrollments from b in DataContext.tbl_batches from c in DataContext.tbl_classes from s in DataContext.tbl_subjects where t.Teacher_ID == e.Teacher_ID && e.Batch_ID == b.Batch_ID && b.Class_ID == c.Class_ID && e.Sub_ID == s.Sub_ID && t.Teacher_Name == "ABC" select t; return View(result.ToList()); I am passing Teacher Name in query and want to get result from two tables , from class & Subject.But, When i create view i can only select one table i.e. tbl_classNow i decided to create a class in controller. I Want to call both my tables in here. A new Model Classnamed MyViewModel will be  created, and I will pass this mod

View Complete Post

More Related Resource Links

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Creating a Validator class for a custom activity

I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

Some help needed for creating a new "struct" to represent elements of a class in a different way....

I'm working on an existing project, where a class is defined as follows:  public class Stat { public DateTime? Date { get; set; } private Dictionary<string, int> _pageViews; public Dictionary<string, int> PageViews { get { if (this._pageViews == null) this._pageViews = new Dictionary<string, int>(); return this._pageViews; } } where the dictionary will store, for each entry, the name of a browser (string) and the # number of pagevisits using that browser(int). So basically, it's like a database table with 3 fields {Date, browser, count} (Each instance of the class is like a record within the table).   What I'm looking for is a way to create a new structure in which the pair {browser- Date/Count}  becomes the PK in DB terms.   Browser        Date                Count--------------------------------------------- Firefox         08/08/2010         20Firefox         08/09/2010         12IE                08/08/2010    

Questions about creating a class that returns multiple values


Hey all,

I am a little stumped, been trying to find some references to this but I am coming up with more confusion than anything else.lol

Here is my scenario using asp.net and VB.

I have an aspx page with about 10 label controls on it and a couple of image controls. Their data will be all populated dynamically by a single URL query string that is passed to a 3rd party url query string that retrieves an xml document with all of the information on it. I am currently just using the page load event and from that I can get everything I need and populate the page elements no problem with all of the code existing on the aspx.vb page.

However I thought for this project as I go forward I would like to create a vb class that handles all of the work instead of using the code behind page which has become quit convoluted.

I am not completely new to creating classes, I've done them before, and some pretty complex however this one is new due to the fact that I want to return multiple values.

So my thought is to approach it this way.

1.       On the page load event I grab the URL query string, and pass it to the vb class to begin the process.

2.       In the class I create a function that loads the xml document into memory.

3.     &n

Pass textbox value to controller class


Hi All

How to pass the textbox value to my controller there is no form and post method in the view

I have taken one input type textbox which is not bind with my model.

I need to access that value to controller

Please give me a solution 

Regarding Creating Custom Field type Class Inheriting from IFieldEditor Interface and UserControl C


How to enable the hidden labels On Create Column Page after selecting our Custom Field type before just ckicking OK so that all those labels appear.

Creating a new Chart Object Inherited from the base chart class with New Initial Settings


I'm creating a new chart object andI want to modify some of the members based on ways that I perfer to use the tool.

At present when I drag and drop my new chart object onto a form, it comes in with the same initial values as the original chart object.

How do I change these initial values?

For example the ChartAreas Collection comes populated with "ChartArea1." I'd like to change this to always say "MyChartArea" along with my specific properties pre-populated (e.g. BorderWidth= 2).

Does anyone know how to do this?

Creating your SharePoint Governance Plan

One of the most common questions that I get from prospects as I'm talking to them about the creation of a governance plan and process is what does it look like. In other words, there are materials available which describe what should be in a governance plan but there isn't a ton of guidance on what the process of creating a governance plan and process are.

Creating Paging for a Repeater Control

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.

Creating an AJAX Repeater in ASP.NET MVC

The "TaskList" is a tried an true example of the most basic thing that you can do in any framework. Unfortunately, I had some problems finding a really good example of all the steps necessary to get a task list to work in ASP.NET MVC 1.0.

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

Creating SharePoint items with CreateItemActivity

Instead of creating new list items from code in your workflow you can use CreateItemActivity. CreateItemActivity can be used for creating list items or files. Properties of interest for this activity are the following (most of them are self-explanatory):

Creating an Excel Spreadsheet programmatically using VB.NET

The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel. This article reveals using Excel from a managed application. Excel is the spreadsheet component of Microsoft Office 2000. The majority of Excel programmatic functionality is exposed through Automation via the type library Excel9.olb. The intention of this article is to express that a managed application can interrelate with Excel as a COM server.

Creating an Excel Spreadsheet and Adding Data to It Programmatically

The Interoperability services make it veryeasy to work with COM Capable Applications such as Word and Excel. Thisarticle reveals using Excel from a managed application. Excel is thespreadsheet component of Microsoft Office 2000. The majority of Excelprogrammatic functionality is exposed through Automation via the typelibrary Excel9.olb. The intention of this article is to express that amanaged application can interrelate with Excel as a COM server.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend