473,654 Members | 3,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1331
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:templateco lumn ItemStyle-VerticalAlign=" Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign ="left" >
<itemtemplate >
<span ><%# GetFirstDocumen tOfRecord( Container.DataI tem) %></span>
</itemtemplate>
</asp:templatecol umn>

GetFirstDocumen tOfRecord 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******** ************@gi ganews.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 GetFirstDocumen tOfRecord 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:templateco lumn ItemStyle-VerticalAlign=" Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign ="left" >
<itemtemplate >
<span ><%# GetFirstDocumen tOfRecord( Container.DataI tem) %></span>
</itemtemplate>
</asp:templatecol umn>

GetFirstDocumen tOfRecord 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 GetFirstDocumen tOfRecord 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:templateco lumn ItemStyle-VerticalAlign=" Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign ="left" >
<itemtemplate >
<span ><%# GetFirstDocumen tOfRecord( Container.DataI tem) %></span>
</itemtemplate>
</asp:templatecol umn>

GetFirstDocumen tOfRecord 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 GetFirstDocumen tOfRecord ( 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******** ************@gi ganews.com...
Thanks for the reply.

I am not sure how I would create the GetFirstDocumen tOfRecord 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:templateco lumn ItemStyle-VerticalAlign=" Top" ItemStyle-Width="110"
ItemStyle-HorizontalAlign ="left" >
<itemtemplate >
<span ><%# GetFirstDocumen tOfRecord( Container.DataI tem) %></span>
</itemtemplate>
</asp:templatecol umn>

GetFirstDocumen tOfRecord 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
3024
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 download a fully working C# sample with the Northwind.mdb here: www.insightgis.com.au/web/stuff/DataGridCombo.zip
1
1847
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 Items.Cell.Count is one. When the grid is displayed the Items.Cell.Count is 7. If anyone has an idea of what might be happening I can post the code used to create the bound columns. Ben
4
2068
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 validation is not firing, even when I leave the field empty. Below please find the code: <%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %>
1
2084
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 do format because it's in a Datagrid pager area. The html code generated for pager is one sigle cell with lots of colspan. I tried to add some html elements in between text and dropdownlist, for example table iframe and p but I cannot achieve...
13
2644
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. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
4
7365
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 close the form via a button on the toolbar (with going to another cell in the datagrid)I want to be able to popup a messagebox to the user asking them if they want to keep their changes. At the momment I'm accomplishing this by a property that...
2
2846
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 appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
9
2713
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 code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
1
2024
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
8708
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8594
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.