I wana get data row in Gridcontrol from the first to the last row. I tried this code but it did work correctly. When I Debug,
string.Concatreturn :
SELECT * FROM viewdulieu2 WHERE Khachdat = N''
This is my Window.xaml
DataTable a = new DataTable();
a = ((DataView)ctrlgridviewdulieu0.ItemsSource).ToTable();
foreach (DataRow row in a.Rows)
{
DataTable dtrow = new DataTable();
dtrow = a.Clone();
dtrow.ImportRow(row);
try
{
cnn.Open();
SqlCommand cmd = new SqlCommand(" SELECT * FROM viewdulieu2 WHERE Khachdat = N'" + dtrow + "'", cnn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
da.Fill(dt1);
XtraReport1 report = new XtraReport1();
report.DataSource = dt1;
// report.Print();
cnn.Close();
report.ShowPreviewDialog();
}
catch (Exception ex)
{
cnn.Close();
MessageBox.Show(ex.Message);
}
This is my Window.xaml.cs
<dxg:GridControl
x:Name="ctrlgridviewdulieu0"
AutoGenerateColumns="AddNew"
EnableSmartColumnsGeneration="True"
HorizontalAlignment="Left"
Margin="0,-12,0,-3"
VerticalAlignment="Top"
Height="592"
Width="176">
<dxg:GridControl.View>
<dxg:TableView/>
</dxg:GridControl.View>
</dxg:GridControl>
I seached many document about this proble and find many supports but they always told about Gridview.Getdatarow, Datagrid or something in WinForm in Win but mine is Gridcontrol and WPF which does not contain .Getdatarow property