Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

datagrid row count in wpf

$
0
0

Hi,

    I have problem to getting datagrid row count in UserControl loaded in wpf...

My coding..

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            viewprojectdetails();
        }

public void viewprojectdetails()
        {
            con = new SqlConnection(cn);
            con.Open();
            SqlCommand cmd = new SqlCommand("viewongoing", con);
            cmd.CommandType = CommandType.StoredProcedure;
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            gvproject.DataContext = dt.DefaultView;
            int a = dt.Rows.Count;
            label3.Content = a.ToString();
            //MessageBox.Show(a.ToString());
            con.Close();
           // loadcount();
        }

in message box shows row count as 19 but if i remove that message box the label shows row count as zero..and also i put this coding in button means its shows row count as 19..i dont know why it will not in user control load...


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>