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

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

ObjectDataSource SelectMethod needs to be updated at runtime

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="CustomGetAllUsers"

MembershipUserCollection userCollection = System.Web.Security.Membership.GetAllUsers();

 protected DataSet CustomGetAllUsers( )
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            dt = ds.Tables.Add("Users");

            dt.Columns.Add("UserName", Type.GetType("System.String"));
            dt.Columns.Add("Email", Type.GetType("System.String"));
            dt.Columns.Add("CreationDate", Type.GetType("System.DateTime"));
            dt.Columns.Add("LastActivityDate", Type.GetType("System.DateTime"));

View Complete Post

More Related Resource Links

ListView calls ObjectDataSource SelectMethod when setting InsertItemPosition


I have a ListView that is bound to an ObjectDataSource. I want to create a new insert item when the user clicks on a button on the form. I do this by reacting to the button click event on the postback. In the button click event, I set ListView.InsertItemPosition = InsertItemPosition.FirstItem.


        protected void NewButton_Click(object sender, EventArgs e)
            // This line causes the ListView's ObjectDataSource to call its SelectMethod
            // Removing this line, the SelectMethod is NOT called.
            itemsListView.InsertItemPosition = InsertItemPosition.FirstItem;


This works, but for some reason the ObjectDataSource's SelectMethod is executed again.

Is there a reason why the SelectMethod of the ObjectDataSource is being called when the ListView's InsertItemPosition is set from None to FirstItem?


ObjectDataSource where SelectMethod returns DataTable has Delete problems


Hello experts,


I have an ObjectDataSource that is configured to use my data access layer class. The select method returns a DataTable. The DeleteMethod takes a System.Guid as a parameter. I am using a FormView object on my page that shows information from the Row of the table and allows paging. In the FormView, I also have a "delete" button with the CommandName attribute set to "Delete".

Without setting anything up, clicking the delete button would send an empty Guid to my delete method. So, I thought it was because my DataKeyNames property of the FormView was empty. So, I set the DataKeyNames property to "SystemId" which is the value from the DataRow of the current item that I would like to use as the primary key. This caused all sorts of problems basically saying that DataObjectTypeName of the the ObjectDataSource did not have a property called "SystemId". I tried adding a DeleteParameters section to the ObjectDataSource and specifying one but had no success.

Obviously, I'm missing a simple step here but I have not been able to figure it out. Below is the markup:


<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    DataObjectTypeName="System.Guid" DeleteMethod="DeletePicture" 
    onobjectcreating="ObjectDataSource1_ObjectCreating" SelectMethod="GetPictures" 

Create And Run Excel Macro At Runtime in C#

You've been tasked with writing a Windows Form application using the .NET Framework that interacts with Microsoft Excel. If you are new to working with Excel in .NET and are having trouble learning how to format certain cells or cell ranges, then this little tip will come in handy. Rather than scour the internet hoping to find the correct set of constants or method syntax for formatting your spreadsheet, use the built in tools in Excel to write the familiar VBA code for you. Then, you can paste the VBA code generated by Excel into the sample C# code below and run it dynamically at runtime.

How to Localize Windows Forms and Change the Language at Runtime

Localization is the process of customizing your application to a particular language, culture or locale. Visual Studio provides support for localizing Windows Forms with much ease. In this article, we will see how to localize windows forms and give the user the ability to change to his preferred language at runtime.
When you run a localized application, the appearance is determined by two culture values. The UICulture property is used to specify which resource files will be loaded for the form. The Culture property, on the other hand, determines how strings such as dates, numerals, and currency amounts are formatted.
Let us see the steps required to create a localized form. You can then expand this example and adopt the same approach for the rest of the forms in your project

Create new sql table at runtime VB.Net


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.

I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!

Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


Binding GridView with SqlDataSource at runtime?


Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot open or save any mo


Hello good people, 

I have this beast as an error. Did my research and found some posts here as well but did not do any good for me. 

Here is what I did. I had an error regarding issue rights with COM objects so I gave access rights under component services for Microsoft Excel application now I am getting this error. 

Here is some information regarding this

1. Gave rights to ASPNET and network service to my web app directory to try to fix this error. 

2. The exact same process works on my Windows 2003 server and my Windows 7 development machine. I am trying to get this going on a different windows 2003 machine that is outside of our domain.

3. Developing on windows 7 64 bit with office 2010 installed. Also excel 2010 is installed on my Web server

4. Here is the code that is causing the error: The last line is causing the error.:

            MyXl = new Microsoft.Office.Interop.Excel.Application();
            MyXl.Visible = false;
            MyWb = (Microsoft.Office.Interop.Excel._Workbook)(MyXl.Workbooks.Add(Missing.Value));
            int test = 0; 
            MySheet = (Microsoft.Office.Interop.Excel._Worksheet)MyXl.ActiveSheet;
            if (reader.HasRows)
                int InRow = 2; 
                for (int i = 0; i < Nu

Runtime development for All mobile device



   I am planning to implement a runtime or Environment . which allow any Mobile application to run on top of IT.

  Please give me couple of links or materials to help me out.

Thanks in advance.


Concurrent Affairs: Four Ways to Use the Concurrency Runtime in Your C++ Projects


This article describes how to integrate the new parallel computing libraries in the Visual Studio 2010 Beta into existing C++ projects. Based on four common scenarios, the column explains a few of the ways developers can use the APIs and classes that are part of the Parallel Pattern Library (PPL), Asynchronous Agents Library, and Concurrency Runtime.

Rick Molloy

MSDN Magazine October 2009

Toolbox: Updated grid controls, open-source comparison tools, and more


This time: Windows Forms grids, professional-looking date textboxes, file merging, and more.

Scott Mitchell

MSDN Magazine November 2007

CLR Inside Out: IronPython and the Dynamic Language Runtime


This column uses the .NET version of the Python programming languages IronPython to demonstrate the value of dynamic languages and the new Dynamic Language Runtime.

Bill Chiles

MSDN Magazine October 2007

Concurrent Affairs: Concurrency and Coordination Runtime


What can a robot-programming toolkit do for you? Read on and find out.

Jeffrey Richter

MSDN Magazine September 2006

Toolbox: Synchronize Data, Review Runtime Errors, and More


This month we bring you products that let you synchronize data, correct runtime errors, and more.

Scott Mitchell

MSDN Magazine August 2006

JIT and Run: Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects


There's lots to explore in the .NET Framework 2.0, and plenty of digging to be done. If you want to get your hands dirty and learn some of the internals that will carry you through the next few years, you've come to the right place. This article explores CLR internals, including object instance layout, method table layout, method dispatching, interface-based dispatching, and various data structures.

Hanu Kommalapati and Tom Christian

MSDN Magazine May 2005

.NET Remoting: Design and Develop Seamless Distributed Applications for the Common Language Runtime


Prior to the advent of .NET, DCOM was the underlying technology for remote communications between Windows-based applications. But DCOM is quirky to set up and configure and not as interoperable as it should be. In .NET, XML Web Services and .NET Remoting are a seamless and effective answer to the demand for tools to build distributed applications.This article provides a primer on .NET Remoting with insights into the internal plumbing. Important aspects of remoting, such as channels, object lifetime management, and clients for remote objects are discussed. In addition, some practical examples are provided.

Dino Esposito

MSDN Magazine October 2002

SQLXML 3.0: Build Data-Driven Web Services with Updated XML Support for SQL Server 2000


XML is becoming the ubiquitous data format on the Web, and XML support in SQL Server is evolving to meet the additional demand. Using XML, SOAP, HTTP, and SQL Server, you can now build powerful Web Services easily. To show just how simple it is with SQLXML 3.0, this article walks the reader through the process step by step, from setting up a virtual directory enabling data access via HTTP to executing queries and building Web Services. Finally, the author illustrates the creation of two Web Services clients-one with C# that works with the Microsoft .NET Framework and one with the SOAP Toolkit 2.0 for anyone still using earlier development tools.

Christian Thilmany

MSDN Magazine May 2002

Microsoft .NET: Implement a Custom Common Language Runtime Host for Your Managed App


While most application developers may not need to write a custom host, understanding what is involved provides a great deal of insight into the architecture of the CLR. After covering how the CLR is started and loaded into a process, how to set the available configuration options, and how a host defines application domains, this article explains how to design a custom host. Important concepts include making the right decisions about the application domain boundaries for the host, configuring them correctly, loading and executing user code, and resolving references to assemblies. Setting security policy and unloading application domains as the application shuts down are also explained.

Steven Pratschner

MSDN Magazine March 2001

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