locked
web form gridview control connected to a data source RRS feed

  • Question

  • User1929727834 posted

    Since I need to support a new webform application, I have a question about how a datasource is connected to the gridview control.

    When I look at the following code:

    <asp:ObjectDataSource runat="server" ID="DataSourceItems"
    TypeName="Items"
    SelectMethod="SelectItems"
    UpdateMethod="UpdateItem"
    DeleteMethod="DeleteItem"
    OnDeleted="OnReturn"
    OnUpdated="OnReturn"
    />

    I see TypeName="Items". What does the typename value mean? Is that the name of the database table?

    Tuesday, June 18, 2019 9:53 PM

Answers

  • User665608656 posted

    Hi dcofomaha,

    According to your description, the TypeName is a partially or fully qualified class name that identifies the type of the object that the ObjectDataSource represents.

    For more detailed explanation, you could refer to this link, it contains a case of GridView binding ObjectDataSource:

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.objectdatasource.typename?view=netframework-4.8

    You could alse take a look at the difference between sqldatasource and ObjectDataSource :

    https://stackoverflow.com/questions/1207295/sqldatasource-vs-objectdatasource

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2019 2:02 AM
  • User-1038772411 posted

    Hello dcofomaha,

    The objectDataSource control represents a middle-tier business object in a multi-tier application. It acts as a data interface for data bound controls such as GridView controls. It enables data bound controls to perform database tasks like retrieval, editing and updating using intermediate middle-tier business object. It provides a structured way for you to bind data bound controls on page to middle-tier business object. You can declaratively bind data bound controls to business objects without writing single piece of code using ObjectDataSource control.

    ObjectDataSource control uses Reflection to expose and call the appropriate methods of a business object to select, insert and update data. You can use Typename property of ObjectDataSource control identifies the class with which ObjectDataSource control works i.e. ObjectDataSource control identifies appropriate class name of business object using its TypeName property and a business object method that is called to retrieve data with its SelectMethod property.Basically, you wire methods at business layer with operations at presentation layer. This way you can have absolute strict control over the flow of the program.

    You can use the ObjectDataSource control with a LINQ to SQL class. To do so, you set the TypeName property to the name of the data-context class.

    For more details kindly refer the following link

    http://www.beansoftware.com/ASP.NET-Tutorials/Data-Source-Controls.aspx

    Thank You

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2019 6:25 AM

All replies

  • User665608656 posted

    Hi dcofomaha,

    According to your description, the TypeName is a partially or fully qualified class name that identifies the type of the object that the ObjectDataSource represents.

    For more detailed explanation, you could refer to this link, it contains a case of GridView binding ObjectDataSource:

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.objectdatasource.typename?view=netframework-4.8

    You could alse take a look at the difference between sqldatasource and ObjectDataSource :

    https://stackoverflow.com/questions/1207295/sqldatasource-vs-objectdatasource

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2019 2:02 AM
  • User-1038772411 posted

    Hello dcofomaha,

    The objectDataSource control represents a middle-tier business object in a multi-tier application. It acts as a data interface for data bound controls such as GridView controls. It enables data bound controls to perform database tasks like retrieval, editing and updating using intermediate middle-tier business object. It provides a structured way for you to bind data bound controls on page to middle-tier business object. You can declaratively bind data bound controls to business objects without writing single piece of code using ObjectDataSource control.

    ObjectDataSource control uses Reflection to expose and call the appropriate methods of a business object to select, insert and update data. You can use Typename property of ObjectDataSource control identifies the class with which ObjectDataSource control works i.e. ObjectDataSource control identifies appropriate class name of business object using its TypeName property and a business object method that is called to retrieve data with its SelectMethod property.Basically, you wire methods at business layer with operations at presentation layer. This way you can have absolute strict control over the flow of the program.

    You can use the ObjectDataSource control with a LINQ to SQL class. To do so, you set the TypeName property to the name of the data-context class.

    For more details kindly refer the following link

    http://www.beansoftware.com/ASP.NET-Tutorials/Data-Source-Controls.aspx

    Thank You

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2019 6:25 AM