ADO.NET DataExtender Task-Based Help / Updating a C1DataView Definition
Updating a C1DataView Definition

This topic shows how to update a view's definition at run time. It assumes you have created a project with two DataGrids bound to a C1DataViewSet and two text boxes. To update the view's definition at run time, add code to the Button_Click events:

  1. Add the following Button1_Click event code:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
       C1DataViewSet1.Views(0).Definition = TextBox1.Text
    End Sub
    

    To write code in C#

    C#
    Copy Code
    private void button1_Click(object sender, EventArgs e)
    {
        C1DataViewSet1.Views[0].Definition = textBox1.Text;
    }
    
  2. Add the following Button2_Click event code:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) ) Handles Button2.Click
       C1DataViewSet1.Views("OrdDetProductView").Definition = TextBox2.Text
    End Sub
    

    To write code in C#

    C#
    Copy Code
    private void button2_Click(object sender, EventArgs e)
            {
            C1DataViewSet1.Views["OrdDetProductView"].Definition = textBox2.Text;
            }
    

The Update button enables the user to make and update changes to the view's definition statement in run time.

Editing at run time:

Observe that the views are filled automatically.



C1DataViewSet1 fills the underlying base DataTable(s) of nwindDataSet1which are referenced in the views (Orders, Order Details and Products in this example) and builds rowsets of views based on the content of those tables. All other DataTable(s) of nwindDataSet1 remain empty.

Testing the Update button:

Sample Available
For the complete sample, see the ViewSet_Define_Fill_Update sample, which is available for download from the ComponentOne HelpCentral Sample page.
See Also