Advertisement

04.22.2008 at 06:45PM PDT, ID: 23345218
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Programmatically set column width in databound gridview

Asked by cnxmax in Programming for ASP.NET, Microsoft Visual Basic.Net, Visual Studio

Tags: , ,

This is my first web site.  I'm using visual studio 2005 to create an ASP.net website with vb.net (I started with "A blank ASP.NET Web site").  I have a gridview whose DataSourceID is set to a SqlDataSource that gets its data from SQLserver 2005.  Every field in the table has a corresponding column in the gridview.  Most columns are visible.  The data comes in fine.  I can update the data using the gridview fine.  In all aspects, but one, things are working as I thought they would when I dragged and dropped things on my *.aspx.  Most of the columns are checkboxes so they look fine; but the columns with string data look bad because they all wrap the text.  So a row that should be one line high is two or three or four lines high.  I have attempted several things as guided by the ever present and always popular WWW but at last nothing is causing my column to get wider.  My code snippet is the last version of the assaults.  Can I (1) set a gridview column width wide enough so the code won't wrap or (2) can I set wrapping off so the column finds a wide enough width to see all the column's words on one line.  Also, and this is just a curiosity, why does the code snippet I found on the WWW multiple by 30?  Any way no matter what I do the column width does not budge.

FYI, when the website comes up the user is asked to browse to a .csv file; after which they push a "download file" button.  The button click routine puts the name of the file in a label control.  The SqlDataSource gets it select parameter from the label control, queries the SQL db and fills the gridview.  Other gridviews do the same thing from various other tables all keyed to the label control text.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Protected Sub GridViewUpdateUnit_RowData1Bound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridViewUpdateUnit.RowDataBound
        Dim drv As System.Data.DataRowView
        drv = CType(e.Row.DataItem, System.Data.DataRowView)
        If e.Row.RowType = DataControlRowType.DataRow Then
            If drv IsNot Nothing Then
                Dim sValue As String = drv("UnitName").ToString()
                Dim iValueLen As Integer = sValue.Length
                If iValueLen > widestData Then
                    widestData = iValueLen
                    GridViewUpdateUnit.Columns(3).ItemStyle.Width = widestData * 30
                    e.Row.Cells(3).Width = widestData * 30
                    GridViewUpdateUnit.Columns(3).ItemStyle.Wrap = False
                End If
            End If
        End If
    End Sub
[+][-]04.22.2008 at 07:28PM PDT, ID: 21417344

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 07:53PM PDT, ID: 21417457

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 07:59PM PDT, ID: 21417474

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 02:15AM PDT, ID: 21418740

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 04:23AM PDT, ID: 21419352

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 06:01AM PDT, ID: 21420146

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 07:28AM PDT, ID: 21421032

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 08:15AM PDT, ID: 21421598

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 08:34AM PDT, ID: 21421829

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 08:40AM PDT, ID: 21421922

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 09:31AM PDT, ID: 21422546

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net, Visual Studio
Tags: microsoft, asp.net, vb.net 2.0
Sign Up Now!
Solution Provided By: l-cm
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.23.2008 at 09:36AM PDT, ID: 21422610

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 05:16PM PDT, ID: 21426708

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 05:40PM PDT, ID: 21426792

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 04:55AM PDT, ID: 21429794

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628