Datagrid column question.

J

JenHu

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.CommandText = "SELECT
Batch_Num,DD_File_Name,Transmit_Date FROM Epay_Batch_Table "
strSql.Connection = conEZDb
strSql.CommandType = CommandType.Text
dataAdapter.SelectCommand = strSql
dataAdapter.Fill(dataSet, "Funding")
Dim FundingInfo As DataTable = dataSet.Tables("Funding")
Dim dvFundingInfo As New DataView(dataSet.Tables("Funding"))
Session("FundingSession") = dvFundingInfo
dvFundingInfo.Sort = strViewString
dgFundStatus.DataSource = dvFundingInfo
dgFundStatus.DataBind()
conEZDb.Close()
Catch err As Exception
End Try
End Sub


The transmit_date column in datagrid:
<asp:BoundColumn DataField="Transmit_Date" HeaderText="Transmit
Date" DataFormatString="{0:MM/dd/yyyy}"></asp:BoundColumn>

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

Keef

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
 
D

David Jessee

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

Text='<%# IIF(Databinder.Eval(.......)=String.Empty,"No Cata
Here",Databinder.Eval(...)) %>'

There's an easier way to do this, depending on your binding....but this will
work.
 
J

JenHu

David Jesseewrote:
Turn the Column into a TemplateColumn.
Then in the aspx file, change the resultant label's binding to:

Text='<%# IIF(Databinder.Eval(.......)=String.Empty,"No Cata
Here",Databinder.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="dgFundStatus" AutoGenerateColumns="False"
Runat="server">
<Columns>
<asp:BoundColumn DataField="Batch_Num" HeaderText="Batch
#"></asp:BoundColumn>
<asp:BoundColumn DataField="DD_File_Name" HeaderText="File
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="File_Status_Description"
HeaderText="File Status"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Transmit Date">
<ItemTemplate>
<asp:label ID="lblTransDate" Runat="server"
Text='<%#IIF(DataBinder.Eval(Container,"DataItem.Transmit_Date")=String.Empty,"No
file
Transmit",Databinder.Eval(Container,"DataItem.Transmit_Date"))%>'></asp:label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top