Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 14088 |  Welcome, Guest!   Register  Login
 Home > Blogs > ASP.NET > Strongly Typed Data Controls Model Binding ASP.NET 4.5 ...
Amitkpatel

Strongly Typed Data Controls Model Binding ASP.NET 4.5

 Blog author: Amitkpatel | Posted on: 6/25/2012 | Category: ASP.NET Blogs | Views: 694 | Status: [Member] | Points: 75 | Alert Moderator   
Ads

Introduction: In the previous version of ASP.NET framework, we have ObjectDataSource control. But now in ASP.NET 4.5 Microsoft integrated ObjectDataSource control with Data Controls. Now Microsoft exposes some property like
3.      DeleteMethod
Purpose: Now developer can easily bind Data controls with the help of SelectMethod and developer can also do other Data Controls operation with the help if UpdateMethod and DeleteMethod.
Code: Download Source Code ModelBindingSample4.5.zip
Step 1: First we will create new Web Application in VS 2011.
Step 2: Now we'll create public method which will return list of objects.
public IQueryable<Customer> GetCustomers()
        {
            IList<Customer> custlist = new List<Customer>();
            custlist.Add(new Customer { ID = 1, Name = "Customer 1", Salary = 1000 });
            custlist.Add(new Customer { ID = 2, Name = "Customer 2", Salary = 2000 });
            custlist.Add(new Customer { ID = 3, Name = "Customer 3", Salary = 3000 });
            custlist.Add(new Customer { ID = 4, Name = "Customer 4", Salary = 4000 });
            custlist.Add(new Customer { ID = 5, Name = "Customer 5", Salary = 5000 });
            custlist.Add(new Customer { ID = 6, Name = "Customer 6", Salary = 6000 });
            custlist.Add(new Customer { ID = 7, Name = "Customer 7", Salary = 7000 });
            custlist.Add(new Customer { ID = 8, Name = "Customer 8", Salary = 8000 });
            return custlist.AsQueryable<Customer>();
        }
public class Customer   
{
        public int ID { getset; }
        public string Name { getset; }
        public int Salary { getset; }
}
Step 3: Now we'll add Data control in aspx page. I have added GridView Control.
  <asp:GridView ID="GridView1" SelectMethod="GetCustomers" AutoGenerateColumns="true"
        PageSize="3" AllowPaging="true" AllowSorting="true" runat="server">
    asp:GridView>
Step 4: Now we'll run our application and see the output.



Amit Kumar Patel
http://blog.iquestionanswer.co.in
http://www.iquestionanswer.co.in
Found interesting? Add this to:


About Amit Patel

Experience:8 year(s)
Home page:http://www.dotnetchuks.com
Member since:Friday, June 22, 2012
Level:Starter
Status: [Member]
Biography:I am Amit Patel, I have 8yrs of experiences in Microsoft technologies. I am very much passionate about Web technology. My core skill is ASP.NET, WCF, C#, JQuery and CSS
>> Write Response - Respond to this post and get points

More Blogs

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 5:18:37 PM