I want to set number of rows of datagrid equal to a number given by user in a textbox. means if i enter 6 in the textbox, it should add 6 rows in the datagrid. thats what i want. I may be wrong. But Null exception is being thrown. How to fix my issue?
Here is the code:
          DataTable dt;
          DataRow dr;
        int rownumber=0;
        dt = new DataTable("emp2");
        DataColumn dc3 = new DataColumn("Wi", typeof(double));
        DataColumn dc4 = new DataColumn("Hi", typeof(double));
        rownumber = Int32.Parse(txtBexNumber.Text);
        dr[rownumber] = dt.NewRow();
        dt.Rows.Add(dr);
        dt.Columns.Add(dc3);
        dt.Columns.Add(dc4);
        datagrid1.ItemsSource = dt.DefaultView;
 
     
    