Welcome to the Xceed Community | Help
Community Search  
More Search Options

Access the controls in Datatemplate of XceedDataGridControl

Sort Posts: Previous Next
  •  08-30-2008, 9:49 AM Post no. 14687

    Access the controls in Datatemplate of XceedDataGridControl

    Hi,

    I have a datagrid control in that  i have added one more column to the grid .

    <xcdg:DataGridControl Grid.Row="2" Loaded="XcDataGrid_Loaded" Name="XcDataGrid" HorizontalAlignment="Left">

    <xcdg:DataGridControl.Columns>

    <xcdg:Column FieldName="pp" Title="pp">

    <xcdg:Column.CellContentTemplate>

    <DataTemplate>

    <TextBox x:Name="mytext" ></TextBox>

    </DataTemplate>

    </xcdg:Column.CellContentTemplate>

    </xcdg:Column>

    </xcdg:DataGridControl.Columns>

    </xcdg:DataGridControl>

    How Can i access the textbox in  the datatemplate  from Code behind ????

  •  09-01-2008, 9:54 AM Post no. 14721 in reply to 14687

    Re: Access the controls in Datatemplate of XceedDataGridControl

    Handle the Loaded event of the TextBox and retrieve your reference in the event handler (the sender will be the TextBox).
    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  09-09-2008, 12:00 PM Post no. 15080 in reply to 14721

    Re: Access the controls in Datatemplate of XceedDataGridControl

    <xcdg:DataGridControl Grid.Row="2" Loaded="XcDataGrid_Loaded" Name="XcDataGrid" HorizontalAlignment="Left">

    <xcdg:DataGridControl.Columns>

    <xcdg:Column FieldName="Txtbox" Title="Txtbox">

    <xcdg:Column.CellContentTemplate>

    <DataTemplate>

    <TextBox x:Name="mytext" ></TextBox>

    </DataTemplate>

    </xcdg:Column.CellContentTemplate>

    </xcdg:Column>

    <xcdg:Column FieldName="chkbox" Title="chkbox">

    <xcdg:Column.CellContentTemplate>

    <DataTemplate>

    <CheckBox   x:Name="Check1" ></CheckBox>

    <CheckBox   x:Name="Check2" ></CheckBox>

    </DataTemplate>

    </xcdg:Column.CellContentTemplate>

    </xcdg:Column>

     

    </xcdg:DataGridControl.Columns>

    </xcdg:DataGridControl>

     

     

    Now in any event of TextBox i want to know which CheckBox is checked ... how can i do this .. I tried to get the current row & then FindName("Check2"); but that is returing a null .

    I also trid to use Name instead of x:Name  to give name to checkBoxes but then also FindName(); is returning null.

    Is there any other way to do this or i m doing something wrong ?????

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.