473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1831
On Tue, 22 Aug 2006 11:04:02 -0700, martin1 <ma*****@discus sions.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_Ce llFormatting(By Val sender As Object, ByVal e As _
System.Windows. Forms.DataGridV iewCellFormatti ngEventArgs) Handles MainGridView.Ce llFormatting
With Me.MainGridView .Columns(e.Colu mnIndex)
Select Case .Name
Case "Scans"
e.Value = IIf(CType(e.Val ue, Boolean), "Yes", "No").ToStr ing

Case "Genre"
e.Value = String.Concat(G etGenreName(CTy pe(e.Value, Integer)), ": ", _
Me.MainGrid.Row s(e.RowIndex).C ells("Style").V alue)
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
7014
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 anyone have any idea how to get this to work? below is the code. Please bear in mind that the function is actually located in a seperate class file from the page that actually returns the grid. ---code for function that returns the grid, this is...
3
3316
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 the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
1
4286
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 have four columns in gridview. Any suggestions guys This is what i used but i keep getting error Private Sub changestyle() GridView1.Columns(1).HeaderText = "First Name"
3
1577
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 GridView is updated with new data the sort does not work. I'm using C# and Ajax for the implementation, below is the code,
2
2116
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 back the proper number of rows. The only thing different I am doing is to display the number of rows returned in the footer of the gridview. The Bindgrid is as follows: Sub BindGrid() Session("reportlevel") = Session("availabilityrptlevel")
1
2614
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 Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Drawing" %> <script language="VB" runat="server"> Public Function GetInActiveDays(ByVal strLastLoginDate As String) As Integer Dim date1 As Date = New...
1
3459
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 to update the value in the DB just change the specific value of the cell that the user will see on the web. Hope I made my self clear.
1
1985
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 change True' and 'False' by 'Yes' and 'No' in normal mode. I tried this, but still get True / False. Thanks for help
1
2079
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 original value, and that's what's being displayed.
0
9641
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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...
1
10080
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
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
8968
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...
0
6735
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2875
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.