Advertisement

05.11.2008 at 12:11PM PDT, ID: 23392973
[x]
Attachment Details

Change header text of gridview column

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

Have the below code and looking to change the column header text. Some of the names have "_" in them and they need to be removed. Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="FormatHighPrices" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CLLDdataSQLConnectionString %>" 
        SelectCommand="test2" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:Parameter DefaultValue="2" Name="ClientID" Type="Int32" />
            <asp:Parameter DefaultValue="container" Name="ShipmentType" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
        <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
        </asp:GridView>
    </div>
    </form>
</body>
</html>
---------------------------------------------------------------------
Partial Class FormatHighPrices
    Inherits System.Web.UI.Page
    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        Dim RemCol As New ArrayList()
        If e.Row.RowType = DataControlRowType.DataRow Then
            For j = 0 To e.Row.Cells.Count - 1
                If IsNumeric(e.Row.Cells(j).Text) Then
                    If e.Row.Cells(j).Text = 1 Then
                        e.Row.Cells(j - 1).BackColor = System.Drawing.Color.Maroon
                    End If
                End If
                If IsDate(e.Row.Cells(j).Text) Then
                    e.Row.Cells(j).Text = System.DateTime.Now.ToString("d")
                End If
            Next
        End If
    End Sub
    Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
        If GridView1.Rows.Count Then
            For Each cell As DataControlFieldCell In GridView1.Rows(0).Cells
                Dim cellColumn As DataControlField = cell.ContainingField
                If cellColumn.HeaderText.Trim.ToUpper.StartsWith("HOLD") Then
                    cellColumn.Visible = False
                End If
            Next
        End If
    End Sub
End Class
[+][-]05.11.2008 at 02:00PM PDT, ID: 21543477

View this solution now by starting your 7-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
Sign Up Now!
Solution Provided By: sinoj
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628