Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datagrid of three columns and I want to add the values for it's rows manually, I want to add these values to it's row:
String Name = "Yasser";
double degree = 98 ;
string Class = "A1";

and this is the XML
XML
<datagrid itemssource="Binding" name="dg_Test" width="Auto" height="312" autogeneratecolumns="&"True"" verticalalignment="Top" horizontalalignment="Stretch" headersvisibility="All" canuserreordercolumns="True" canuserresizecolumns="True">
                          CanUserSortColumns="True"  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" BorderBrush="Gray" BorderThickness="2" HorizontalGridLinesBrush="Red" VerticalGridLinesBrush="Red"
                          AlternationCount="2" AreRowDetailsFrozen="False" CanUserResizeRows="False" RowDetailsVisibilityMode="Visible" RowHeight="20" SelectionMode="Single" FlowDirection="RightToLeft" Margin="0,36,0,0" Grid.RowSpan="2" CanUserAddRows=vTrue" CanUserDeleteRows="True"
            <DataGrid.Columns">
                <DataGridTextColumn Header="Student Name" Width="200" </DataGridTextColumn>
                <DataGridTextColumn Header="Student Grade" Width="200" </DataGridTextColumn>
                <DataGridTextColumn Header="Student Class" Width="200" </DataGridTextColumn>
        </DataGrid.column>
</DataGrid></datagrid>
Posted
Updated 4-Mar-11 2:27am
v3
Comments
Slacker007 4-Mar-11 7:30am    
Please reformat your your question so that it looks better. Thanks.
Sunasara Imdadhusen 4-Mar-11 8:46am    
What is your problem?
Yasser El Shazly 4-Mar-11 9:00am    
how
Yasser El Shazly 4-Mar-11 9:10am    
how can i add each value of these in it is related column in the data grid..?
Yasser El Shazly 4-Mar-11 9:11am    
Yasser under the column Student name , and 98 under the column Student Grade ...etc

1 solution

You should write RowDefinitions to add rows.Below article will give you a better idea on how to acheive this.

http://www.c-sharpcorner.com/Resources/Detail.aspx?ResourceId=676[^]

From this,as you have columns added already,utilize the part required for row addition.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900