473,785 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid column question.

I have a datagrid (dgFundStatus) which displays a [Transmit_Date]
column.
When the Transmit_Date is null, how can I show "Not transmit yet"
instead of null?

Thanks.
Sub BindData()
Dim strSql As New SqlCommand
Dim dtrDataGrid As SqlDataReader
Dim dataAdapter As New SqlDataAdapter
Dim dataSet As New DataSet
Dim FilePath As String
If Not conEZDb.State = ConnectionState .Open Then
conEZDb.Open()
End If
Try
If Not IsPostBack Then
strSql.CommandT ext = "SELECT
Batch_Num,DD_Fi le_Name,Transmi t_Date FROM Epay_Batch_Tabl e "
strSql.Connecti on = conEZDb
strSql.CommandT ype = CommandType.Tex t
dataAdapter.Sel ectCommand = strSql
dataAdapter.Fil l(dataSet, "Funding")
Dim FundingInfo As DataTable = dataSet.Tables( "Funding")
Dim dvFundingInfo As New DataView(dataSe t.Tables("Fundi ng"))
Session("Fundin gSession") = dvFundingInfo
dvFundingInfo.S ort = strViewString
dgFundStatus.Da taSource = dvFundingInfo
dgFundStatus.Da taBind()
conEZDb.Close()
Catch err As Exception
End Try
End Sub
The transmit_date column in datagrid:
<asp:BoundColum n DataField="Tran smit_Date" HeaderText="Tra nsmit
Date" DataFormatStrin g="{0:MM/dd/yyyy}"></asp:BoundColumn >

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 19 '05 #1
3 1137
Hi Jen,

I suppose you could do a validation on the [Transmit_Date] column to check
whether the value is null, then assign the appropriate result to a
dynamically created column to replace the bound column "Transmit_Date" .

Not too sure if its the most effective way, but I hope it helps.
Best Regards

"JenHu" <je**********@h otmail-dot-com.no-spam.invalid> wrote in message
news:41******** **@Usenet.com.. .
I have a datagrid (dgFundStatus) which displays a [Transmit_Date]
column.
When the Transmit_Date is null, how can I show "Not transmit yet"
instead of null?

Thanks.
Sub BindData()
Dim strSql As New SqlCommand
Dim dtrDataGrid As SqlDataReader
Dim dataAdapter As New SqlDataAdapter
Dim dataSet As New DataSet
Dim FilePath As String
If Not conEZDb.State = ConnectionState .Open Then
conEZDb.Open()
End If
Try
If Not IsPostBack Then
strSql.CommandT ext = "SELECT
Batch_Num,DD_Fi le_Name,Transmi t_Date FROM Epay_Batch_Tabl e "
strSql.Connecti on = conEZDb
strSql.CommandT ype = CommandType.Tex t
dataAdapter.Sel ectCommand = strSql
dataAdapter.Fil l(dataSet, "Funding")
Dim FundingInfo As DataTable = dataSet.Tables( "Funding")
Dim dvFundingInfo As New DataView(dataSe t.Tables("Fundi ng"))
Session("Fundin gSession") = dvFundingInfo
dvFundingInfo.S ort = strViewString
dgFundStatus.Da taSource = dvFundingInfo
dgFundStatus.Da taBind()
conEZDb.Close()
Catch err As Exception
End Try
End Sub
The transmit_date column in datagrid:
<asp:BoundColum n DataField="Tran smit_Date" HeaderText="Tra nsmit
Date" DataFormatStrin g="{0:MM/dd/yyyy}"></asp:BoundColumn >

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 19 '05 #2
Turn the Column into a TemplateColumn.
Then in the aspx file, change the resultant label's binding to:

Text='<%# IIF(Databinder. Eval(.......)=S tring.Empty,"No Cata
Here",Databinde r.Eval(...)) %>'

There's an easier way to do this, depending on your binding....but this will
work.
"JenHu" <je**********@h otmail-dot-com.no-spam.invalid> wrote in message
news:41******** **@Usenet.com.. .
I have a datagrid (dgFundStatus) which displays a [Transmit_Date]
column.
When the Transmit_Date is null, how can I show "Not transmit yet"
instead of null?

Thanks.
Sub BindData()
Dim strSql As New SqlCommand
Dim dtrDataGrid As SqlDataReader
Dim dataAdapter As New SqlDataAdapter
Dim dataSet As New DataSet
Dim FilePath As String
If Not conEZDb.State = ConnectionState .Open Then
conEZDb.Open()
End If
Try
If Not IsPostBack Then
strSql.CommandT ext = "SELECT
Batch_Num,DD_Fi le_Name,Transmi t_Date FROM Epay_Batch_Tabl e "
strSql.Connecti on = conEZDb
strSql.CommandT ype = CommandType.Tex t
dataAdapter.Sel ectCommand = strSql
dataAdapter.Fil l(dataSet, "Funding")
Dim FundingInfo As DataTable = dataSet.Tables( "Funding")
Dim dvFundingInfo As New DataView(dataSe t.Tables("Fundi ng"))
Session("Fundin gSession") = dvFundingInfo
dvFundingInfo.S ort = strViewString
dgFundStatus.Da taSource = dvFundingInfo
dgFundStatus.Da taBind()
conEZDb.Close()
Catch err As Exception
End Try
End Sub
The transmit_date column in datagrid:
<asp:BoundColum n DataField="Tran smit_Date" HeaderText="Tra nsmit
Date" DataFormatStrin g="{0:MM/dd/yyyy}"></asp:BoundColumn >

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 19 '05 #3
> David Jesseewrote:
Turn the Column into a TemplateColumn.
Then in the aspx file, change the resultant label's binding to:

Text='<%# IIF(Databinder. Eval(.......)=S tring.Empty,"No Cata
Here",Databinde r.Eval(...)) %>'


Thank you David. I am trying to use your suggestion in my code and
didn't get it work so far. PLEASE HELP!

here is my new code:
<asp:datagrid id="dgFundStatu s" AutoGenerateCol umns="False"
Runat="server">
<Columns>
<asp:BoundColum n DataField="Batc h_Num" HeaderText="Bat ch
#"></asp:BoundColumn >
<asp:BoundColum n DataField="DD_F ile_Name" HeaderText="Fil e
Name"></asp:BoundColumn >
<asp:BoundColum n DataField="File _Status_Descrip tion"
HeaderText="Fil e Status"></asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Tra nsmit Date">
<ItemTemplate >
<asp:label ID="lblTransDat e" Runat="server"
Text='<%#IIF(Da taBinder.Eval(C ontainer,"DataI tem.Transmit_Da te")=String.Emp ty,"No
file
Transmit",Datab inder.Eval(Cont ainer,"DataItem .Transmit_Date" ))%>'></asp:label>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 19 '05 #4

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

Similar topics

5
2279
by: AC | last post by:
Any reason i'm having trouble with: DataGrid1.Columns(7).ItemStyle.HorizontalAlign = HorizontalAlign.Right I'm trying to directly set the column alignment of a datagrid created at runtime.. AC
3
1548
by: ruca | last post by:
Hi, I have two different questions to ask: QUESTION 1: Can I create dinamically a column in a datagrid? How? I have a datagrid that must have 5 columns, but in some very special cases I have to add another column. How can I do this in code? QUESTION 2:
12
2012
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the conversion is extremely costly in performance. Does anybody know how I could set the label (of the whole content of the TableCell) to .Visible = False without converting e.Item.Controls(2) to a System.Web.UI.WebControls.Label?
1
2483
by: Drew | last post by:
Hey, thanks in advance for helping me out with my problem: I have a datagrid which is embedded in another datagrid. The datagrid is filled directly by a dataset generated from a sql query. So far everything is fine. Now i try to format the embedded datagrid - e.g. setting font size and the column size/width of each column. Everything is working fine, except the width of the columns.
13
2496
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for them. In a plain vanilla DataGrid, when you click on the RowHeader, the appropriate row changes colors. I ASSUME this should be done in the Paint (or PaintText) override of the DataGridColumnStyle in question. My problem is that I don't know...
4
1812
by: Anthony | last post by:
Hi Folks, I'm adding some columns to my datagrid which are of Combo Box type. I'm inheriting DataGridTextBoxColumn and doing all the usual stuff to get them populated. This is working fine. I have added some functionality where if the user right clicks the combobox a context menu will appear, saying "Fill the complete column with value 'XXX'". This value is the value they selected from the combobox. This is also working fine. However,...
13
1860
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql query: OleDbDataAdapter1.SelectCommand.CommandText = & _ "Select illNameE From tblIllness" OleDbDataAdapter1.Fill(DsIllness1) But in my datagrid, I get (null) for other ccolumns instead
10
2346
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option. If the user right clicks on a column heading can I highlight that column and then delete it? I'm not exactly sure how to highlight it or figure out what column has been clicked. In my testing so far when I use the context menu I always get the...
4
3114
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll horizontally to view these coloumn names. So I want to group them into categories which will fit into a page. A user clicks a category and the category should
5
2910
by: rn5a | last post by:
In my application, I want to populate all the directories & files existing in a directory on the server in a DataGrid. To ensure that all the directories get listed first followed by all the files, I am appending all the directories with 0 & all the files with 1. Moreover, each directory & file listed in the DataGrid will have a corresponding CheckBox. To differentiate between directories & files, I am adding the string "*D" (without the...
0
9645
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
10327
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
9950
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
8973
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
6740
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?
1
4053
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
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.