Datagrid column header text change

How to change the datagrid (MyDatagrid) column hedare text via load event without using itemdatabound event.

Datagrid name: MyDatagrid

column 2 text = OrderNo

Thank you very much for the helpful info.



7/15/2008 4:02:29 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 45

You can't! The Page.Load event is too early in the Page life cyce. You must wait until the ItemDataBound event or after.

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

7/15/2008 4:07:12 PM

Can you please tell me, how to change the header text of datagrid in the itemdatabound.



7/15/2008 4:11:49 PM

  void DataGrid1_itemDataBound(object sender, DataGridItemEventArgs e)
        if (e.Item.ItemType == ListItemType.Header)

If this solves your problem please mark as answer
7/15/2008 4:18:27 PM

Similar Artilces:

How to change the Header Text of a datagrid column dynamically?
Hi ,  Can any one guide me on how to change the header text of a datagrid column dunamically in code behind? i am using the follwing code in datagrid item databound, but its not working  if (e.Item.ItemType == ListItemType.Header) {  if (Session["RoleID"].ToString() == "6" | Session["RoleID"].ToString() == "13") { e.Item.Cells[5].Text = "Select Record"; }Pradeep My personal way of doing it is to define a custom header. Then I can grab an instance of a lable or literal control in this instance in the ItemdataBound ev...

Weekdays changing dynamically in Datagrid Column Header Texts
Dear All,I hav a prob.I hav a table t_custinfo containing customer ID,name and personal details.Now I hav a datagrid where in I hav to retrieve custID and custname in two columns.In other columns I need to display weekdays say Mon to Sun with dates..The weekdays hav to change dynamically.In the grid user enters the amount collected from the customers for ex:CustID Custname Mon-2/2/06 Tue-3/2/06 Wed-4/2/06....till Sun-..1      bharath   100          2000      1000   2  ...

Changing column header text of a gridview inside user control
Hi,I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that:foreach (DataControlField col in GridView1.Columns){ col.HeaderText = GetString(col.HeaderText);}However, no matter where I place that code, the header texts return to their original value, and that's what's being displayed.What could be the reason for that? And how can it be solved?  ...Anyone? I'm having the feeling that I'm missing something quite basic here, any help would be very appreciated. Amit00: col.HeaderT...

Change datagrid header text
I have a datagrid and I need to programatically change each column's header text based on user's previous input. I put the code in OnItemDataBound event like this:  if (e.Item.ItemType == ListItemType.Header) {  for (int i = 0; i <= e.Item.Cells.Count - 1; i++)  { e.Item.Cells[i].Text = "something"; } } The header text did get changed, but it changed it into static text which is not clickable so sorting cannot be performed. How do I change the header text but still make sorting enabled?It's been bothering me for a while now ... thanks a lot! Penn i am surprised ...

Changing Header Text on a Datagrid
I have headers that post back to sort - I am attempting to change the text with each sort so as to indicate that is the current sort column and the sort direction howevere when I  do something like this it wipes out the link - can anyone please advise how to  thanks in advanve If e.Item.ItemType = ListItemType.Header Then e.Item.Cells(i).Text = "whatever" End If I've never had to do anything like that before, but i think you have to find the link in the header and change the text value. Do a google search, i'm sure something will pop up.  DarmarkMark as Answer, if ...

Changing the datagrid header text
Is this possible at all? I have an application that runs in different languages and I want to display the header in the current language (stored in the session). Thanks in advance Heki Yes, it is defenetely possible. You will have to use resource files to achieve that. Idea is - there will be one resource file to store the default string values and one resource file for each language you want to support. So, say i add two resource files to my project: MyForm.resx and first being the default resource and second containing versions of the strings in Russian. ...

Changing Header Text of Datagrid Programatically
I have a datagrid. It is bound to an object data source.  I want to change the header text in one of the columns each time the data changes – which is basically at every postback.   By way of background, I created template fields using the Fields dialog box.  I have listed a portion of the code from the datagrid I am working on below.  I want to programmatically change  the headertext “services”.  I have tried using  findcontrol but I keep getting a null exception.  Any ideas would be appreciated. Thanks   <asp:TemplateField HeaderText=&...

DataGrid Autogenerated Columns Header Text
How do I change the header text of an autogenerated columns of a datagrid? you don't ;) . . . try boundcolumns. -Joejoe Good help.... And if you have a runtime generated datagrid with a variable number of columns use a bound column? Think again.... If anyone can post something useful to do this, I'm sure the advanced users here would appreciate it. TIA natalismon This works: Private Sub drgFoo_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles drgFoo.ItemCreated 'The cells() array hol...

Change Header Text in the DataGrid on Selection.
Hi,  I have a problem in inserting a combo box in to a Data grid Header which has an Img when click it has to display the Combobox for selection of the new column name.I created a control which has a Span, Select box and an Img when clicks on the Img, it shows the select box for column selection and displays the column name in the span innertext.But i am unable to use the same control for different columns as i used Div for hiding and displaying the combo box. Can you please give me an idea on how to improve these sort of controls, which i can use mulitple times on the same webpag...

Programmatically Change Datagrid Header Text
Hi, Can anyone please tell how to programmatically change the header text of a datagrid ? Thanks Phillip You have to change the header text in the ItemDatabound event. if(e.Item.ItemType = ListItemType.Header) { //If you have placed a label in the header.... Label lbl = e.Item.Controls[1] as Label; lbl.Text = "New header text"; } Also note that DataGridItem is derived from TableRow so you can do a lot of customizing.Mike Schellenberger - MCAD...

How to retrieve controls in column header of a DataGrid?
I have controls in column header of a my DataGrid control grdDocumentDate. I use grdDocumentDate.FindControl() to look for the controls in column header but could not get them. Is there any way to solve the problem? ImageButton ib = (ImageButton)grdDocumentDate.FindControl("ibDocDate");ib always returns null.<asp:datagrid id="grdDocumentDate" style="Z-INDEX: 118; LEFT: 24px; POSITION: absolute; TOP: 176px" runat="server" BorderWidth="0px" AllowSorting="True" AutoGenerateColumns="False" OnItemCommand="ShowMoreDetailsCommand" BackColor="Silver"    Width="704px"> ...

change column header text (SaveAs)
I'm saving the content of my datawindow as Excels (SaveAs) but the name of the header column are not the name as on screen. Meaning the header on my column is Name and then my rows shows the names, but SaveAs gives first_name as my header. Is there a way we can change the header when saving as Excels. thanks in advance. Mike Hi Mike; The SaveAs grabs the column names from the DW buffer not the labels. So what you will see are the raw column names or some hybrid of the table and column name together. That is the DW Painters default at construction time. So .....

Datagrid: Header text spanning more than 1 column
Hi all, Is it possible to have a column header spanning more than 1 column in a datagrid? Any pointers would be appreciated! Figured it out ! ... well: Oddly, I get an extra column??? which I the "delete". Any pros out there who can offer some slick code would be appreaciated. Bit of a fudge but works a treat! For anyone else with the same problemo: In the ItemDataBound event handler ... If e.Item.ItemType = ListItemType.Header Then e.Item.Cells(3).ColumnSpan = 2 e.Item.Cells.RemoveAt(4) End If Looks good to me.Darrell Norton, MVPDarrell ...

Can you control selectability of DataGrid column headers?
We have a DataTable with sorting enabled.  The person that I am working for has a complaint:  he wants the user to be able to select a column for sorting whenever the mouse is over the text in the header text of the column;  as things stand now, the cursor must be positioned  just below the text before the browser will allow selection.  Is there a way to control this, or  is this functionality that is internal to the browser? This behavior appears to only be an issue in Internet Explorer, not Firefox. the sort headers are simply an anchor...

Web resources about - Datagrid column header text change -

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 12/5/2015 11:40:36 AM