Datagrid row height changes depending on number of items?

A

Andre Ranieri

I'm fairly new to datagrids, I hope folks bear with me. . .

I've added several bound datagrids to a web application I'm creating; I added the datagrids themselves in design view with the columns as part a collection in the datagrid control properties. The datagrid is bound to a dataset in run-time, using the following code.

I've noticed that the height of the header, footer and individual rows in the datagrid is variable depending on how many rows are in my dataset table. If there's only a couple rows the header and rows are ridiculously tall; if there are 5-10 rows they're much shorter. Is there anything I can do to make the height of the individual rows uniform regardless of how many rows appear in the datagrid?

Thanks,

Andre



DataTable SchedServices = ds.Tables["SchedServices"];
DataColumn dcDateScheduledString = new DataColumn ("DateScheduledString", typeof(string));
SchedServices.Columns.Add(dcDateScheduledString);
SchedServices = ds.Tables["SchedServices]"];
dgSchedServices.DataSource=ds.Tables["SchedServices"];
if( ds.Tables["SchedServices"].Rows.Count!=0)
{
//Format null Date Scheduled to read "Not Scheduled"
foreach (DataRow dsRow in ds.Tables["SchedServices"].Rows)
{
dsRow["DateScheduledString"] = dsRow["DateScheduled"] + "";
if (dsRow["DateScheduledString"].ToString() == "")
{
dsRow["DateScheduledString"]="Schedule Pending";
}
if (dsRow["Service"].ToString().Substring(0,2) == "43")
{
dsRow["DateScheduledString"]= "Weather dependant";
}
}

DataView source = new DataView(ds.Tables["SchedServices"]);
dgSchedServices.DataSource = ds.Tables["SchedServices"] ;
dgSchedServices.DataBind();
 
A

Andre Ranieri

I finally figured this one out, and wanted to share. If you clear the height from the datagrid's properties, the row height is the same regardless of number of rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top