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

in behind code, how can i read(or write) at specific cell

3 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kim
Top achievements
Rank 1
kim asked on 29 Jun 2010, 05:53 PM
 i added unbound GridViewColumn (uniquename flag) in RadGridView.

when i clicked "add button" 
how can i write(or read) a data in flag column at behind code.

<Button Content="add new" Height="23" HorizontalAlignment="Left" Margin="770,0,0,0" Name="button5" VerticalAlignment="Top" Width="75" Click="button5_Click" />
       <telerikGridView:RadGridView HorizontalAlignment="Left" Margin="12,69,0,0" Name="dataGrid1" VerticalAlignment="Top" Height="279" Width="1000" EditTriggers="CellClick" IsSynchronizedWithCurrentItem="True" RowIndicatorVisibility="Visible" ShowGroupPanel="False" AutoGenerateColumns="False" DataContext="{Binding}">
            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewColumn UniqueName="flag" Width="20" />
                <telerikGridView:GridViewDataColumn Header="사번" Width="60" DataMemberBinding="{Binding emp_no, Mode=TwoWay}" HeaderTextAlignment="Center" IsFilterable="False" />
                <telerikGridView:GridViewDataColumn Header="성명" Width="80".........................


-----------------------------------------------
behind code
------------------------------------------------

        private void button1_Click(object sender, RoutedEventArgs e)
        {
           //DataRow row = dataGrid1.Items.AddNew();
           //row["flag"] = "I";
           //row["reg_date"] = DateTime.Today.ToString("yyyyMMdd");
        }

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 30 Jun 2010, 06:01 AM
Hello kim,

The correct way to do this is to the use updated the properties of the underlying data item. For example, if you would like to change the "emp_no" column you should get the item that should be updated from the Items collection of RadGRidView and update the "emp_no" property. If the data items support INotifyPrpertyChanged the grid will pick up the change and refresh its UI.


Sincerely yours,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
david mcintyre
Top achievements
Rank 1
answered on 26 Jul 2010, 09:21 PM
My problem is that I am able to add a new row in codebehind and rebind.  I would like to customize the value of a single cell because the new custom value for that cell has a datatype that does not match the underlying dataobject.  In my case, the grid's first column serves as a rowheader, and the underlying datatype is an integer (which displays the year for the rest of the data in the row).  But the dynamically-added rows need to have text.  So how can i add these rowheader labels if i can't add them to the underlying itemssource?
0
Vlad
Telerik team
answered on 27 Jul 2010, 06:26 AM
Hello,

 You can always have view model on the top of your original data and add desired additional property. 

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
kim
Top achievements
Rank 1
Answers by
Milan
Telerik team
david mcintyre
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or