BoundColumn Problöem

Rahul Sharma <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.general
Message-ID <8B9B8D6FC105D44EB77D8F3EC0E6FCCF0D9E74@proserv>
Hi,

I have this ASPX file:
//DataGrid.aspx

<%@ Page language="c#" Codebehind="DataGrid.aspx.cs" AutoEventWireup="false" Inherits="DataControls.DataGrid" %>
<HTML>
        <HEAD>
                <title>DataGrid</title>
                <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
                <meta name="CODE_LANGUAGE" Content="C#">
                <meta name="vs_defaultClientScript" content="JavaScript">
                <meta name="vs_targetSchema" content=" http://schemas.microsoft.com/intellisense/ie5">
        </HEAD>
        <body MS_POSITIONING="GridLayout">
                <form id="DataGrid" method="post" runat="server">              
                <asp:DataGrid id="DataGrid1" AutoGenerateColumns="False" style="Z-INDEX: 101; LEFT: 30px; POSITION: absolute; TOP: 21px" runat="server" BorderColor="Tan"       BorderWidth="1px" BackColor="LightGoldenrodYellow" CellPadding="2" GridLines="None" ForeColor="Black">
                                <SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
                                <AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
                                <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
                                <FooterStyle BackColor="Tan"></FooterStyle>
                                <PagerStyle HorizontalAlign="Center" ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>
                                <Columns>
                                        <asp:BoundColumn DataField="Title" HeaderText='<%= GetHeader("TILES") %>'>
                                        </asp:BoundColumn>
                                </Columns>
                        </asp:DataGrid>
                </form>
        </body>
</HTML>


and CODE-BEHIND:
//DataGrid.aspx.cs

namespace DataControls
{
        /// <summary>
        /// Summary description for DataGrid.
        /// </summary>
        public class DataGrid : System.Web.UI.Page
        {
                protected System.Web.UI.WebControls.DataGrid DataGrid1;
       
                private void Page_Load(object sender, System.EventArgs e)
                {
                        // DB is a Database wrapper to execute Stored Procedures
                        DB db = new DB();
                        // Setting the DataSource as GetAllData() is returning a DataSet 
                        DataGrid1.DataSource = db.GetAllData();
                        DataGrid1.DataBind();
                }

                public string GetHeader(String Text){
                        return Text;
                }

                #region Web Form Designer generated code
                        //Automated Code
                #endregion
        }
}


Now problem starts when I try to set the Header Text of BoundColumn in ASPX file like this: 

<asp:BoundColumn DataField="Title" HeaderText= '<%= GetHeader("TITLES") %>' >  </asp:BoundColumn> 

OR

<asp:BoundColumn DataField="Title" HeaderText= '<%  GetHeader("TITLES") ; %>' >  </asp:BoundColumn>  

I get nothing as Header Text But no error reported, and when I try to set it as DataBound Value like this:

<asp:BoundColumn DataField="Title" HeaderText= '<%# GetHeader("TITLES") %>' >  </asp:BoundColumn> 

I get error back that BoundColumn doesn't support DataBinding.

 

I don't understand how to do this, I could do it on runtime only in the code behind file but couldn't get any way to do it in ASPX file.

 

Any Pointers....

 

Thanks.

 

Rahul.

 

 

 

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.