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


Post New Web Links

configure ObjectDataSource from Code Behind in C#

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net
 

Hi All,

I have an ObjectDataSource and I want to configure it from code behind , I want to set the InsertMethod , Selectmethod from Code Behind and set it to my Business Layer files

Please help me as soon as you can

Thanks in Advance




View Complete Post


More Related Resource Links

Control this objectdatasource programatically from the code behind based on different button clicks

  
I have a page where you can search and display other data, very simple layout. 1 Gridview and 1 objectdatasource. But i have 4 possible buttons that can populate the gridview.. i would like to control my objectdatasource from the code behind based on the button you click. here is what i have right now.. but if possible, can this source not be hardcoded like this and only built in the code behind? <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectDVRInfo" TypeName="DataAccessCode"> <SelectParameters> <asp:ControlParameter ControlID="ddlDVR" Name="dvrInfo" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> I found this site with a solution to this persons issue, but i cant seem to get mine working this way. http://stackoverflow.com/questions/2404264/overwriting-controlparameters-of-datasources-in-code-behind I have  this as the code behind right now when you press the button.. what other parameter settings am i missing and is this the right order to populate them for the source to acknowledge my values?   ObjectDataSource1.SelectMethod = "SelectDVRInfo"; ObjectDataSource1.SelectParameters["MyParameter"]

how to configure objectdatasource

  
Hello, I was wondering if someone could help me with this problem.   First of all, I created my own stored procedure in SQL Server for my aspnetdb database which is :   view plaincopy to clipboardprint? USE [C:\USERS\DAVE\DESKTOP\AUG 19 NEW ONE\APP_DATA\ASPNETDB.MDF]   GO      CREATE PROCEDURE [dbo].[aspnet_GetNotifications]   (       @UserName               nvarchar(256)   )   AS   SELECT UserName,UserNotification,UserNotificationDate   FROM UserNotifications WHERE UserName=@UserName   So, the procedure gets everything from the UserNotifications table, except the RecordID(primary key) which is not needed for display. Now I have set up my BLL and DAL, and everything is working fine, in my DAL, I have the tableadapter and it is called PersonalRecordEntries.xsd in which I have added queries to it using existing stored procedures. Such as : GetLastRecordEntryDate(@UserName) which returns one value which of course is the last record entry date. InsertRecord(@UserName,@TDEE,@BMI,@FTM) which does not return any values, it only inserts a record. AND LASTLY GetNotifications(@UserName) which is supposed to return UserName, UserNoti

Enabling Paging on ObjectDataSource that is built dynamically in code behind

  

I have the following on my aspx page

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="DataAccessCode" SelectMethod="SelectDVRInfo" OnSelected="ObjectDataSource1_Selected">
    </asp:ObjectDataSource>


Then in my code behind i have the following set up in 4+ button events, since each button serves a different purpose.. Prior to this past week, i was only working with 2 gridviews on the page.. that were linked to this datasource.. so everything was fine.. but recently had to add a Datalist to display the results a certain way.. I got it all working, but now that more records are in the table the datalist is growing in length on the page and cant figure out how to modify the current code to enable paging without having to redesign the logic all together to get it enabled.

Based on what i have below and above, is there a solution i can implement to implement paging ONLY for the Datalist? Or if it cant be specific, if enabled, will it affect the gridview that is already configured to enable paging, which already works?

 

                ObjectDataSource1.SelectMethod = "SelectDVRInfo";
                ObjectDataSource1.SelectParameters.Clear();
                ObjectDataSource1

Binding an ObjectDataSource to a property in aspx code, not code-behind

  

This should be simple to do, but I haven't been able to find a solution.

I want to bind an ObjectDataSource to a property in my asp page and I want to do it in the page's aspx code, not in code-behind. I've already done it in code-behind, as follows:

protected void Page_InitComplete(object sender, EventArgs e)
{
   odsBooks.DataSource = SelectedBook;
   odsBooks.DataBind();
}

I'd prefer to get rid of the ugly code-behind and just do this in mark-up. Something like

<asp:ObjectDataSource ID="odsBooks" runat="server"
     DataObjectTypeName="BookCatalogue.InteractionDocuments.Book" 
     DataSource="SelectedBook"/>

This gives me a run-time error: Cannot create an object of type 'System.Object' from its string representation 'SelectedBook' for the 'DataSource' property.

Is there a way of doing this declaratively and not in code-behind?

Further, what if what I want is to actually use a child property of the property in question? For example, if my Book object has a ReaderComments collection, can I databind to it decaratively in the aspx mark-up?


Subject: BUG? Empty Business Object when Configure ObjectDataSource

  
Hi,

I would like to bind an ObjectDataSource control in my page to a method of 
one of the existing classes in my App_Code folder. However, when I go 
"Configure Data Source..." for this control, the wizard shows an empty 
drop-menu for business object, and I can't choose any of my classes

All my classes in the App_Code compile successfully and I don't understand 
what is causing this problem. Is there a bug?


WB.

Configure ContentQuerywebpart by code

  

Hello ,

 

 is there any sample to configure contentquery webpart by code ?

 

  thanks


ASk

Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

  
When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

  
You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

  
Free C# Code Snippets

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Microsoft StyleCop: Source Code Analyzer for C#

  
StyleCop is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while StyleCop analyzes the source code directly. For this reason, FxCop focuses more on the design of the code, while StyleCop focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.

Code spelling checker extension for visual studio 2010

  
Building a spelling checker for source code as an extension for visual studio 2010.

C# and XML Source Code Documentation

  
Through many years of enterprise level software development and consulting, I became critically aware of the importance of good source code documentation, and several years ago when I began working with the first release of Visual Studio .NET beta 1 and found C# provided built-in support for inline XML code documentation, I was thrilled.

Bar Code Scanners with the .NET Compact Framework

  
Summary: Learn how to make your applications use bar code scanners in a generic way-ndependent of the specific bar code scanners that are used on different devices. Using the design patterns Façade and Factory, the implementation not only supports multiple bar code scanners, but it also makes it easy to add support for other bar code scanners. After a brief discussion about bar code scanners and the bar code scanner pattern, a download code sample, written in C#, demonstrates the use of the pattern and technologies.

PrinterCE for .NetCF - Code Samples

  
1)Example:Hello World
2)Example:Form Test
3)Example:DrawTextFlow
4)Example:TextColumns
5)Example: Bar Code Test
6)Example:Text Wheel
7)Example:Image Rotation
8)Example:Line Fun

.net code converter

  
For coverting your programming langugae to another languge the below site is very help full

http://www.developerfusion.com/tools/convert/vb-to-csharp/
Categories: 
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