Cell Height

J

JOhn

Hi,
I have a datagrid on a form in VS.NET. When the grid has
5 or so items in it the cell height looks great. However,
sometims the grid only has 1 or 2 rows. When this happens
the cell heights get real tall and it looks stupid. Is
there some way to specify that the cell heights should be
constant. I looked at the properties and nothing jumped
out as an obvious answer. I have one template column with
a checkbox in it and 5 databound columns.
I hope the answer will be in VS.NET since I don't want to
muck around with the html.

Thanks,
john
 
M

Mike Moore [MSFT]

Hi John,

I have not been able to reproduce your problem. I dragged a datagrid onto a
form and filled it from the Pubs database. I tried it with a dozen records
and then again with just two. In both cases the row height was the same.

Can you post instructions for reproducing your problem?

Here are the instructions to reproduce my test.

* drag a datagrid onto a web form.
* add the following to the code-behind (and adjust the connection string as
needed). This will select two records from the pubs database.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Bind()
End If
End Sub

Private Sub Bind()
Dim Qry1 As System.Data.SqlClient.SqlDataReader
Dim connectionString As String = "server='localhost';
trusted_connection=true; Database='pubs'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT top 2 au_id, au_lname, au_fname FROM
authors"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Qry1 =
sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
DataGrid1.DataSource = Qry1
DataGrid1.DataBind()
Qry1.Close()
sqlCommand.Dispose()
sqlConnection.Close()
sqlConnection.Dispose()
End Sub


Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
A

Alvin Bruney

This happens because you have set a height on the datagrid property sheet
remove that height and compress the datagrid as far short as it will go.
that will fix the problem. with the height, the contents are stretched to
honor the height requirements dynamically.
hope this helps
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top