HI,
Can some one please help me with a datagrid layout problem am having. Please see image below to see the problem:
<img src="
As you can see the data in each column do not line up, there broken up by new line spaces:
my code is shown below: I think the problem is due to me using the "dr = dt.NewRow(); line 22;" in the loop, Is there another way of declaring dr so that it does inseart newrow each time. or any idea's on how to fix this problem.
1 myDataAdapter.SelectCommand.CommandText = "SELECT recordid2,criteria,department,subheading," + pupids + " FROM [" + schooltid + "recordcriteriatbl] where department=@Field1l and recordtitle=@Field2l";
2
3 myDataAdapter.SelectCommand.Parameters.Add("@Field1l", dep);
4 myDataAdapter.SelectCommand.Parameters.Add("@Field2l", record);
5 SqlCommandBuilder custCB = new SqlCommandBuilder(myDataAdapter);
6
7
8
9 DataSet custDS = new DataSet();
10 myDataAdapter.Fill(custDS, "recordtitle");
11
12 foreach (DataTable table in custDS.Tables)
13 {
14 foreach (DataRow row in table.Rows)
15 {
16
17 string criteriaid = System.Convert.ToString(row["recordid2"]);
18 string criteria = System.Convert.ToString(row["criteria"]);
19 string sub = System.Convert.ToString(row["subheading"]).Trim();
20
21
22 dr = dt.NewRow();
23 if (sub == intArray[0])
24 {
25 dr[0] = criteria;
26 }
27 if (sub == intArray[1])
28 {
29 dr[1] = criteria;
30 }
31 if (sub == intArray[2])
32 {
33 dr[2] = criteria;
34 }
35 if (sub == intArray[3])
36 {
37 dr[3] = criteria;
38 }
39
40 dt.Rows.Add(dr);
41 }
42
43
44
45 }
Thank you for your time and help
Can some one please help me with a datagrid layout problem am having. Please see image below to see the problem:
<img src="
As you can see the data in each column do not line up, there broken up by new line spaces:
my code is shown below: I think the problem is due to me using the "dr = dt.NewRow(); line 22;" in the loop, Is there another way of declaring dr so that it does inseart newrow each time. or any idea's on how to fix this problem.
1 myDataAdapter.SelectCommand.CommandText = "SELECT recordid2,criteria,department,subheading," + pupids + " FROM [" + schooltid + "recordcriteriatbl] where department=@Field1l and recordtitle=@Field2l";
2
3 myDataAdapter.SelectCommand.Parameters.Add("@Field1l", dep);
4 myDataAdapter.SelectCommand.Parameters.Add("@Field2l", record);
5 SqlCommandBuilder custCB = new SqlCommandBuilder(myDataAdapter);
6
7
8
9 DataSet custDS = new DataSet();
10 myDataAdapter.Fill(custDS, "recordtitle");
11
12 foreach (DataTable table in custDS.Tables)
13 {
14 foreach (DataRow row in table.Rows)
15 {
16
17 string criteriaid = System.Convert.ToString(row["recordid2"]);
18 string criteria = System.Convert.ToString(row["criteria"]);
19 string sub = System.Convert.ToString(row["subheading"]).Trim();
20
21
22 dr = dt.NewRow();
23 if (sub == intArray[0])
24 {
25 dr[0] = criteria;
26 }
27 if (sub == intArray[1])
28 {
29 dr[1] = criteria;
30 }
31 if (sub == intArray[2])
32 {
33 dr[2] = criteria;
34 }
35 if (sub == intArray[3])
36 {
37 dr[3] = criteria;
38 }
39
40 dt.Rows.Add(dr);
41 }
42
43
44
45 }
Thank you for your time and help