By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Datagrid column question.

P: n/a
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
*-----------------------*
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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**********@hotmail-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.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
*-----------------------*

Nov 19 '05 #2

P: n/a
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.
"JenHu" <je**********@hotmail-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.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
*-----------------------*

Nov 19 '05 #3

P: n/a
> 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.T ransmit_Date")=String.Empty,"No
file
Transmit",Databinder.Eval(Container,"DataItem.Tran smit_Date"))%>'></asp:label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

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

This discussion thread is closed

Replies have been disabled for this discussion.