This is a migrated thread and some comments may be shown as answers.

How I to do an automatic insert into a radgrid with needneedsource

3 Answers 302 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tonyz289
Top achievements
Rank 1
Tonyz289 asked on 22 Oct 2011, 09:51 PM
I have RadGrid that uses NeedDataSource and it works fine. What I can't figure out in how to do an automatic insert, since the examples I could find do it in the DataSource definition in aspx code.

Can someone point me to an example  or a tutorial, please?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Oct 2011, 05:28 AM
Hello Tony,

The automatic data source operations only work when binding the grid to a declarative data source using the DataSourceID property of the RadGrid. Here is the help documentation and demo which explains more about this.
Automatic DataSource Operations.
Grid / Automatic Operations.

Thanks,
Shinu.
0
Tonyz289
Top achievements
Rank 1
answered on 24 Oct 2011, 03:12 PM
Rats, I am using NeedDataSource because I am using different SelectMethod's and TypeName's to make a common form taking one data item from various tables. See code below.
I was hoping I could use automatic insert to add new data to the tables.
How would you recommend I do this (with an example please)?
private void chooseDataMethods ()
{
    if (!String.IsNullOrWhiteSpace (Request.QueryString["list"]))
    {
        ObjectDataSource DataSource1 = new ObjectDataSource ();
        RadGrid1.DataSource = DataSource1;
 
        String list = Request.QueryString["list"];
 
        switch (list)
        {
            case "documenttypes":
                DataSource1.SelectMethod = "getDocumentTypes";
                DataSource1.TypeName = "ip3v4.BusinessLayer.DocumentTypeBAL";
                break;
            case "advertisernames":
                DataSource1.SelectMethod = "getNames";
                DataSource1.TypeName = "ip3v4.BusinessLayer.AdvertiserBAL";
                break;
            case "markets":
                DataSource1.SelectMethod = "getNames";
                DataSource1.TypeName = "ip3v4.BusinessLayer.MarketBAL";
                break;
            case "advertisercategories":
                DataSource1.SelectMethod = "getNames";
                DataSource1.TypeName = "ip3v4.BusinessLayer.AdvertisingCategoryBAL";
                break;
            case "productcategories":
                DataSource1.SelectMethod = "getNames";
                DataSource1.TypeName = "ip3v4.BusinessLayer.ProductCategoryBAL";
                break;
            default:
                break;
        }
    }
}

0
Shinu
Top achievements
Rank 2
answered on 25 Oct 2011, 08:35 AM
Hello Tony,

Automatic Insert/Delete/Update is only possible for Declarative DataSource. In case of NeedDataSource you can explicitly write the queries for Insert/update/Delete operations. You can take a look into the following documentation

Insert/Update/Delete at Database Level with Queries

Thanks,
Shinu.
Tags
Grid
Asked by
Tonyz289
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tonyz289
Top achievements
Rank 1
Share this question
or