473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing the gridview header text

hi
i'm trying to change the gridview columns header text

the columns are not auto generated, i have set specific headertext
values for each column

i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.

what i'm actually trying to do and is not working :

protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}

the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text

any idea when the header text if filled in ?

Mar 8 '07 #1
8 31963
Try RowCreated event.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"fredd00" <fr************ *@gmail.comwrot e in message
news:11******** **************@ q40g2000cwq.goo glegroups.com.. .
hi
i'm trying to change the gridview columns header text

the columns are not auto generated, i have set specific headertext
values for each column

i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.

what i'm actually trying to do and is not working :

protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}

the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text

any idea when the header text if filled in ?

Mar 8 '07 #2
On Mar 8, 1:34 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Try RowCreated event.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin

"fredd00" <frederic.nou.. .@gmail.comwrot e in message

news:11******** **************@ q40g2000cwq.goo glegroups.com.. .
hi
i'm trying to change the gridview columns header text
the columns are not auto generated, i have set specific headertext
values for each column
i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.
what i'm actually trying to do and is not working :
protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}
the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text
any idea when the header text if filled in ?
Hi

I did try the row created event but the tc.Text is always ""

any other idea ?

Mar 8 '07 #3
How do you set the headers?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"fredd00" <fr************ *@gmail.comwrot e in message
news:11******** **************@ c51g2000cwc.goo glegroups.com.. .
On Mar 8, 1:34 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Try RowCreated event.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin

"fredd00" <frederic.nou.. .@gmail.comwrot e in message

news:11******** **************@ q40g2000cwq.goo glegroups.com.. .
hi
i'm trying to change the gridview columns header text
the columns are not auto generated, i have set specific headertext
values for each column
i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.
what i'm actually trying to do and is not working :
protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}
the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text
any idea when the header text if filled in ?

Hi

I did try the row created event but the tc.Text is always ""

any other idea ?

Mar 8 '07 #4
On Mar 8, 5:15 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
How do you set the headers?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin

"fredd00" <frederic.nou.. .@gmail.comwrot e in message

news:11******** **************@ c51g2000cwc.goo glegroups.com.. .
On Mar 8, 1:34 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Try RowCreated event.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
"fredd00" <frederic.nou.. .@gmail.comwrot e in message
>news:11******* *************** @q40g2000cwq.go oglegroups.com. ..
hi
i'm trying to change the gridview columns header text
the columns are not auto generated, i have set specific headertext
values for each column
i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.
what i'm actually trying to do and is not working :
protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}
the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text
any idea when the header text if filled in ?
Hi
I did try the row created event but the tc.Text is always ""
any other idea ?
they are in the grid view declaration

<Columns>
<asp:BoundFie ld DataField="titr e" HeaderText="Tit le"
SortExpression= "titre" meta:resourceke y="BoundFieldRe source1" />
<asp:BoundFie ld DataField="Desc ription"
HeaderText="Des cription" SortExpression= "descriptio n"
meta:resourceke y="BoundFieldRe source2" />
<asp:BoundFie ld DataField="Lang ue" HeaderText="Lan gue"
SortExpression= "langue" meta:resourceke y="BoundFieldRe source3" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="Dure e"
HeaderText="Dur ation" SortExpression= "Duree"
meta:resourceke y="BoundFieldRe source4" >
<ItemStyle HorizontalAlign ="Right" />
</asp:BoundField>
<asp:BoundFie ld DataField="STD" HeaderText="STD "
SortExpression= "std" meta:resourceke y="BoundFieldRe source5" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="ID_O ffre" HeaderText="ID"
meta:resourceke y="BoundFieldRe source6" />
</Columns>

when are the values inserted in the grid and when can i retrieve them ?

Mar 9 '07 #5
On Mar 8, 5:15 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
How do you set the headers?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin

"fredd00" <frederic.nou.. .@gmail.comwrot e in message

news:11******** **************@ c51g2000cwc.goo glegroups.com.. .
On Mar 8, 1:34 pm, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Try RowCreated event.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
"fredd00" <frederic.nou.. .@gmail.comwrot e in message
>news:11******* *************** @q40g2000cwq.go oglegroups.com. ..
hi
i'm trying to change the gridview columns header text
the columns are not auto generated, i have set specific headertext
values for each column
i want to change the header text based on the specific header text. i
want to load a new text from a global resource file.
what i'm actually trying to do and is not working :
protected void RowDataBound(ob ject sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header) //
DataControlRowT ype.DataRow
{
foreach (TableCell tc in e.Row.Cells)
{
string s =
(string)GetGlob alResourceObjec t("General", tc.Text);
if (s != null)
{
tc.Text = s;
}
}
}
}
the problem is that tc.Text is always ""
if i'm going through a DataControlRowT ype.DataRow there is text in
tc.Text
any idea when the header text if filled in ?
Hi
I did try the row created event but the tc.Text is always ""
any other idea ?

i set the header text in the gridview declaration

<Columns>
<asp:BoundFie ld DataField="titr e" HeaderText="Tit le"
SortExpression= "titre" meta:resourceke y="BoundFieldRe source1" />
<asp:BoundFie ld DataField="Desc ription"
HeaderText="Des cription" SortExpression= "descriptio n"
meta:resourceke y="BoundFieldRe source2" />
<asp:BoundFie ld DataField="Lang ue" HeaderText="Lan gue"
SortExpression= "langue" meta:resourceke y="BoundFieldRe source3" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="Dure e"
HeaderText="Dur ation" SortExpression= "Duree"
meta:resourceke y="BoundFieldRe source4" >
<ItemStyle HorizontalAlign ="Right" />
</asp:BoundField>
<asp:BoundFie ld DataField="STD" HeaderText="STD "
SortExpression= "std" meta:resourceke y="BoundFieldRe source5" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="ID_O ffre" HeaderText="ID"
meta:resourceke y="BoundFieldRe source6" />
</Columns>
when does the header text binding occur , when can i retrieve the
header text values ?

Mar 9 '07 #6
here is my solution that works :

protected virtual void RowDataBound(ob ject sender,
GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header)
{
foreach (TableCell cell in e.Row.Cells)
{
foreach (Control ctl in cell.Controls)
{
if (ctl.GetType() == typeof(LinkButt on))
{
string s =
(string)GetGlob alResourceObjec t("General", "title");
if(s !=null)
{
((LinkButton)ct l).Text = s;
}
}
}
}

}
}

Mar 9 '07 #7
oups her is the fixed one

protected virtual void RowDataBound(ob ject sender,
GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header)
{
e.Row.Cells[5].Visible = false;
//e.Row.Cells[5].Text = string.Empty;
e.Row.Cells[5].Width = Unit.Pixel(1);

foreach (TableCell cell in e.Row.Cells)
{
foreach (Control ctl in cell.Controls)
{
if (ctl.GetType() == typeof(LinkButt on))
{
LinkButton btn = (LinkButton)ctl ;
string s =
(string)GetGlob alResourceObjec t("General", btn.Text);
if(s !=null)
{
btn.Text = s;
}
}
}
}

}
}
Mar 9 '07 #8
here is the fix

foreach (DataControlFie ldCell cell in e.Row.Cells)
{
foreach (Control ctl in cell.Controls)
{
LinkButton link = ctl as LinkButton;
if (link != null)
{
string s =
(string)GetGlob alResourceObjec t("General", link.Text);
if (s != null)
{
link.Text = s;
}
}
}
}

Mar 9 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1603
by: Herry | last post by:
Hi all, I have problem with datagrid in asp.net using vb as the language. This is how I show the datagrid from database datagrid1.datasource = dataset1 datagrid1.DataBind() Is there any possibility to change the header on every column and how to set the column width
3
3470
by: Hans Merkl | last post by:
Hi, I was wondering if it's possible to bind the header text of a GridView column to a method of an object I have. At the moment I am setting the header texts in Page_Load but I was wondering if I can do with databinding. thanks Hans Merkl
2
5779
by: Mark Rae | last post by:
Hi, Is there a bug in the GridView control specifically related to wrapping of header text...? E.g. the following tag <asp:GridView HeaderStyle-Wrap="false" ID=gvListUsers runat=server ... etc .... > does not prevent the header text from wrapping.
2
11574
by: sck10 | last post by:
Hello, I have the following for a GridView. How do you break the HeaderText into two lines. I tried using: HeaderText="Revenue <br /> Impact", but that doesn't work. Any help would be appreciated. -- Thanks in advance,
0
1923
by: pargat.singh | last post by:
Hi Everyone: I have a gridview control with AllowSorting="True" and work ok. But my page will be used by different user from different region so i need to change the HeaderText based on language like english or french etc.When i updat ethe header on GridView1_RowCreated sorting does not work anymore. Below are my code. Is this because of...
4
9444
by: TS | last post by:
I have a headerText for a header column that is "Page<br>Name". it puts a <brto force a line break, but the < and get encoded to &lt; and &gt; thus negating its effect as an html control and doesn't respect the line break I'm guessing this happens during render. What do i need to do to keep the line break?
7
12948
by: rote | last post by:
I would like to make my Gridview header dynmic i.e databinded from database.. I want my users to be able to change the headers on the fly.. Any ideas?
1
2069
by: Amit00 | last post by:
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...
0
1912
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I am using a CssClass to fix the gridview header in ASP.Net 2005(C#),which is working fine in IE..But not working in Firefox..This is the cssclass which I'm using right now WrapperDiv { background-image: url(tdbg.jpg); color: #002F5C;
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.