locked
Object DataSource RRS feed

  • Question

  • User-667042492 posted

    hi,

    i have a custom gridview and its source is a list<myClass> .. when i want to load its datasource items on RowUpdating event,

    i couldnt get updating row's item from its source.. my code is like this;

    1    object obj = this.DataSource;
    2                    Type type = obj.GetType();
    3                    PropertyInfo[] pInfo = type.GetProperties();
    4    
    5                    Assembly sysAss = Assembly.Load(pInfo[2].PropertyType.Assembly.FullName);
    6                    type = sysAss.GetType(pInfo[2].PropertyType.FullName, false, true);
    7                    obj = Activator.CreateInstance(type); 
    

     in line 7 i can load myClass but its new and its properties are not load..

    i m using like this, because custom grid's datasource is one of my classes, and i want to update

    my Class using its public Update method. how can i get original data from grids datasource, which is updating row?

    thanks..

    Saturday, May 24, 2008 6:55 AM

All replies

  • User853727733 posted

     Unfortunately the DataSource doesn't keep it's value from one request to another. Once the Grid is populated with it's value and the response is sent you'll not be able to get the DataSource object in the next request. Normally the way to go is to perform the same operation you did before to get the object that was attributed to the DataSource and then use this object.

    You can also the the values from the GridViewUpdateEventArgs argument in the event.

    Hope this helps. 

    Saturday, May 24, 2008 10:00 AM
  • User-667042492 posted

    thanks for your reply gbogea,

    like your said, datasource is coming from my object, otherwise its value is null.. forget this, i change my code, there is a problem too,

    onrowupdating im using GridViewUpdateEventArgs e and e.OldValues also empty.. i dont know why?

    thanks in advance..

    Saturday, May 24, 2008 10:29 AM