473,407 Members | 2,546 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,407 software developers and data experts.

change gridview text

Hi, All,

Anyone knows how to change gridview text info? specifically the gridview
populate from sql db, first column is string rather than number, i want to
change first row in first column into another string, for example "Book" ,
but I don't want this chnage to affect database.

Thanks
Aug 22 '06 #1
1 1819
On Tue, 22 Aug 2006 11:04:02 -0700, martin1 <ma*****@discussions.microsoft.comwrote:
>Hi, All,

Anyone knows how to change gridview text info? specifically the gridview
populate from sql db, first column is string rather than number, i want to
change first row in first column into another string, for example "Book" ,
but I don't want this chnage to affect database.

Thanks

I'm not sure, but I think you are after something like this using the CellFormatting Event:

Private Sub MainGridView_CellFormatting(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DataGridViewCellFormattingEve ntArgs) Handles MainGridView.CellFormatting
With Me.MainGridView.Columns(e.ColumnIndex)
Select Case .Name
Case "Scans"
e.Value = IIf(CType(e.Value, Boolean), "Yes", "No").ToString

Case "Genre"
e.Value = String.Concat(GetGenreName(CType(e.Value, Integer)), ": ", _
Me.MainGrid.Rows(e.RowIndex).Cells("Style").Value)
End Select

End With
End Sub

In the above, in the column named "Scans", the db's Boolean values are displayed as a string value
rather than True or False.

In the column named "Genre", a concacted string is displayed which consists of a string value based
on the db's genre integer value, plus the string value from a hidden column named "Style".
You can also use "e.RowIndex" to target specfic cells.
Gene

Aug 22 '06 #2

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

Similar topics

1
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
1
by: Sharon | last post by:
Hello All, I have a gridview control in webform which is dynamically populated on page startup with a query. I was trying to change the header text for the columns and also set wrap to false. i...
3
by: Ashton | last post by:
Hello, I have a GridView; once the page is loaded I can sort it just fine, I can sort it as many times as I would like, I can sort any of the columns. After clicking on Search and the...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
1
by: dhaneshrs | last post by:
I have a small code that shows inactive and active users from the ms access DB. <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %> <%@ Import...
1
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
Hi all, From my DATABASE i get Dataset to my GRIDVIEW. On run time I want to change the value of a cell. For example: Instead of "0" i want to write "N/A". let's make it clear - I don't want...
1
by: Ben | last post by:
Hi, The gridview contains a radiobuttonlist with boolean values (true/false) coming from a database. In normal mode, the gridview displays True or False for that field. What i want is to...
1
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)...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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,...
0
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...

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.