Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
Problem With User Control
posted

Hi..

I created one user control.this control contains a xamdatagrid with some data taking from one class.

Now i use this control as it is in one window.Now i want to add one new record to this control.

here i want to add this new record means..

Xamdatagrid1.datasource property is not there...how to bind new record to this control.

when i write code for button click new record is not adding..

Can u suggest some sample code to work with user controls to add modify and delete data.

Here i m using xml as my data source..

 

Please give reply as soon as possible.

 

Thank u in advance.

Parents
  • 69686
    posted

    Hello,

    I am not sure I understand the whole problem. How is the DataSource property not there?

    Which is your data source - xml or data from a class?

    Assuming that your control is in the main window, you can access it and get reference to the grid inside it like this:

     XamDataGrid xamDataGrid = Infragistics.Windows.Utilities.GetAncestorFromType(myUserControl, typeof(XamDataGrid), false) as XamDataGrid;

    Then you can get its DataSource and add new records in it -

     

    BindingList<int> integers = control.xamDataGrid1.DataSource as BindingList<int>;

    integers.Add(2);

    Alex.

     

     

     

     

Reply Children