473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Webform Datagrid question - Altering text in a cell

All:

I've looked all over (and probably not in the right places) to try and
find some example code, or documentation on how I can modify the text in
a cell of a datagrid.

I've found information saying it's best to override the paint method,
and other information saying it's best to use the prerender event.

Can anyone point me in the right direction? Thanks and sorry for the
dumb question, I'm trying to learn C# coming from a Perl background. :)

-Sam
Nov 17 '05 #1
4 1322
Hi,

there is no paint event in webforms, you can either use prerender event or
calling a method at bind time, below is an example of the latter :

<asp:templatecolumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign="left" >
<itemtemplate>
<span ><%# GetFirstDocumentOfRecord( Container.DataItem) %></span>
</itemtemplate>
</asp:templatecolumn>

GetFirstDocumentOfRecord is a protected method declared in the code behind.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sam Evans" <wi******@gmail.com> wrote in message
news:wZ********************@giganews.com...
All:

I've looked all over (and probably not in the right places) to try and
find some example code, or documentation on how I can modify the text in a
cell of a datagrid.

I've found information saying it's best to override the paint method, and
other information saying it's best to use the prerender event.

Can anyone point me in the right direction? Thanks and sorry for the dumb
question, I'm trying to learn C# coming from a Perl background. :)

-Sam

Nov 17 '05 #2
Thanks for the reply.

I am not sure how I would create the GetFirstDocumentOfRecord though.
Am I going through the DataGrid items list to get it?
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

there is no paint event in webforms, you can either use prerender event or
calling a method at bind time, below is an example of the latter :

<asp:templatecolumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign="left" >
<itemtemplate>
<span ><%# GetFirstDocumentOfRecord( Container.DataItem) %></span>
</itemtemplate>
</asp:templatecolumn>

GetFirstDocumentOfRecord is a protected method declared in the code behind.
cheers,

Nov 17 '05 #3
Nevermind, I figured out a different way to do it..

Using the ItemDataBound event in the datagrid I was able to modify the
e.Item[0].Cells.Text

Thanks, though!

Sam Evans wrote:
Thanks for the reply.

I am not sure how I would create the GetFirstDocumentOfRecord though. Am
I going through the DataGrid items list to get it?
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

there is no paint event in webforms, you can either use prerender
event or calling a method at bind time, below is an example of the
latter :

<asp:templatecolumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign="left" >
<itemtemplate>
<span ><%# GetFirstDocumentOfRecord( Container.DataItem) %></span>
</itemtemplate>
</asp:templatecolumn>

GetFirstDocumentOfRecord is a protected method declared in the code
behind.
cheers,

Nov 17 '05 #4
Hi,

It's a method declared in the code behind like this:

protected string GetFirstDocumentOfRecord ( object o )
{
//do whatever
return "the text you want";
}

The good thing about this is that it's mucho more clear the process and you
can modify it easily

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sam Evans" <wi******@gmail.com> wrote in message
news:K4********************@giganews.com...
Thanks for the reply.

I am not sure how I would create the GetFirstDocumentOfRecord though. Am I
going through the DataGrid items list to get it?
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

there is no paint event in webforms, you can either use prerender event
or calling a method at bind time, below is an example of the latter :

<asp:templatecolumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign="left" >
<itemtemplate>
<span ><%# GetFirstDocumentOfRecord( Container.DataItem) %></span>
</itemtemplate>
</asp:templatecolumn>

GetFirstDocumentOfRecord is a protected method declared in the code
behind.
cheers,

Nov 17 '05 #5

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

Similar topics

3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
1
by: Ben Cox | last post by:
I have a DataGrid on a WebForm which has one column added in the design properties of grid and 6 BoundColumns added in c# code. The grid displays properly but in the Edit event the...
4
by: Luis Esteban Valencia | last post by:
I have a asp.net page (C#), with a datagrid. I use template for all columns, and have <asp:requiredfieldvalidator> in with one of the textboxes, to make sure it's filled in. However, this...
1
by: strout | last post by:
I know it's dumb ... sometimes frustrating I want the text and a dropdownlist align with both side of a table cell, i.e. text align left and dropdownlist align right. I cannot add more cells to...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to...
2
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
1
by: Tarik Monem | last post by:
Hi everyone and I hope that you can help. I am trying to send a value of a cell within a Datagrid to my php file which has a simple sql query: here's the php: <? $server = "localhost";
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.