.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

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

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
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    

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

LINQ to SQL compiler error CS1519: Invalid token 'void' in class, struct, or interface member decl

I get the following compiler errors when creating my first LINQ to SQL class (I just dragged a table "ProfileExtended" onto the designer and hit build):DataClasses.designer.cs(31,11): error CS1519: Invalid token 'void' in class, struct, or interface member declaration these are the offending lines of autogenerated code:#region Extensibility Method Definitions  partial void OnCreated();  partial void InsertProfileExtended(ProfileExtended instance);  partial void UpdateProfileExtended(ProfileExtended instance);  partial void DeleteProfileExtended(ProfileExtended instance);  #endregion

Marshal C++ Struct to C# class?

Is it possible to have the Marshaller move a C++ struct to a C# class? I defined the C# class with StructLayout Explicit, and mapped it. It works perfectly as a struct, but if I change to class, I get a buffer overflow. Is there some way to work around this? I need to add methods to these "classes", and making a wrapper class that has all the same fields seems like such a waste.

advice needed on implementing a re-usable class (c#)

Hi guys,Im trying to create a function for my website that allows the re-sizing of images for different purposes. I want the function to use variables for image height and image width, and obviously for the file itself. I have working test code for re-sizing a selected image that is hard-coded into the function. I have created it in a separate class in my App_Code folder, and have tried calling it on web pages and it works until I try and pass a filename as a variable, encountering a variety of errors. Should I be using a server control/user control to do this? or do I need something else?RegardsPooleo

Creating class in controller

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

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

Help needed with creating Pdf table out of list of dataSets


Hey there,

I'm trying to create a pdf table using data from a list of datasets.

Each dataset may contain 0 to 4 rows as follows, and the data within that dataset is specific to a particular month:


CommunicationType         CommunicationCount
email                                           20
letter                                           10
phone                                           5
fax                             &n

Serialize a Class's properties as XML Attributes instead if Elements


Say you have a 3rd party provided assembly with a class like so:

User user = new User();

user.UserId = 1;
user.UserName = "johndoe";
user.Password = "password";


When serialized with the XmlSerializer it comes out something like this:


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.

Help needed using Class and EntityDataModel



I'm trying to study mvc and I have found my self dealing with this problem/ question


I have a DB with the table Customer and I have create a Entity data model  (with the table customer).

Now I have also made a class name customer and I'm getting an error saying "

                Missing partial modifier on declaration of type 'MvcSite.Models.Customer'; another partial declaration of this type exists   



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcSite.Models
    public class Customer
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public Address Address { get; set; }
    public class Address
        public string Street { get; set; }
        public string City { get; set; }
        public int Zip { get; set; }



What I'm trying to do is using this class to write new costumers to the DB , ( I do know how to do so directly , but if I'm not Mistaking using the class is the Correct way to do so (?)

If I'm changing the class name to customers , how is it suppose to wri

Creating dynamic elements in an html table


I need to create 3 buttons in addition to 2 text values (which come out fine) in a row for a table.

However, the buttons are coming out as straight input text fields even though I specifiy  "button" as the type for the td attribute.

Below is my js.

How can I set up these buttons as actual buttons instead of input text fields? Notice the boldfaced code below which is coming out as just input text boxes instead of buttons.

    var tr = document.createElement('tr');
    var td1 = document.createElement('td');
    var td2 = document.createElement('td');
    var td3 = document.createElement('td');
    var td4 = document.createElement('td');
    var td5 = document.createElement('td');

    //Up button

creating xml emements , nodes as needed


not sure where to submit this query
i a using sql2000 and vs 2005

i am generating a xml file from sql data thr' code

the xml file thats created does not have the proper tree struture as need
i need elements/ sub, child elements. nodes  grouped as per the patter given
i even need to get the first line
<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
which i am not able to get

so how do i query the data so that i gte the specified tree view

currently i hve
Select * from tbl Order by id

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.
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