when to dynamically change datagrid column headers

G

gh0st54

hi

still working on changing my data grid headers using resource files

the thing is i always gat a count of 0 for my datagrid columns count, when
will i get the columns count and when should i change the headers ??

thanks

private void Page_Load(object sender, System.EventArgs e)

{

this.sqlDataAdapter1.Fill(this.emp1,"Employees");

this.DataGrid1.DataBind();

Response.Write("columns :" + this.DataGrid1.Columns.Count);

// Put user code to initialize the page here

SetUI();

if(!Page.IsPostBack)

{

this.txtCulture.Text = Thread.CurrentThread.CurrentCulture.Name;

}

private void SetUI()

{

double d = 10.25;



Thread.CurrentThread.CurrentCulture = new
CultureInfo(this.txtCulture.Text);

Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture;


ResourceManager rm = new
ResourceManager("Demo.Strings",System.Reflection.Assembly.GetExecutingAssemb
ly());



if(Page.Controls.Count>1){

foreach( System.Web.UI.Control ctrl in
Page.FindControl("Form1").Controls) {


this.lblIds.Text += "<br/>Control : " + ctrl.ClientID.ToString()
+ " Control type" + ctrl.GetType().ToString();

//Response.Write();

if (ctrl.GetType().ToString() ==
"System.Web.UI.WebControls.DataGrid"){

DataGrid dg = (System.Web.UI.WebControls.DataGrid )ctrl;

foreach (DataGridColumn col in dg.Columns){


this.lblIds.Text += " <br/> Column header text :" +
col.HeaderText ;

}

}


}

}


// then use rm to set text


}
 

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,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top