Display partial information on Dataset

S

Stephen

Hi,

Suppose there is a column in the dataset that is a very large field (say
varchar(500)) and i want to display partial information with (....) so that
the user can click on it to view for more.
(I dont want to truncate any info in the dataset...)
How can display partial information in a datagrid?

Thanks,
Stephen
 
K

Kerem OZMAN

Well you can use some UI tricks there but it depends on how you display your
dataset. For example, if your dataset has a table with a large field bound
to a GridView then you can use GridView's RowDataBound event and put some
code that visually trims your data. Here is a sample considering a GridView
which has some simple bound fields (place it in RowDataBound event handler
method of a GridView):
//Assuming your GridView displays two fields Title and FirstName
// in that order.

if(e.Row.RowType == DataControlRowType.DataRow)
{
//e is the GridRowEventArgs and Cells[1] is the FirstName field of a
//particular row. And assume any FirstName has minimum length of
//2 characters
e.Row.Cells[1].Text = e.Row.Cells[1].Text.Substring(0, 2);
// So you trimmed down your FirstName field to 2 characters.
}

It's not the best way but solution depends on the scenario you are working
on.
 
S

Stephen

Thanks kerem,

I found another solution I used
<%# DataBinder.Eval(Container.DataItem,
"Description").ToString().Substring(0, length) & "..." %>
in Itemtemplate

Appreciate your input....
and I think I need to graduate to V2.0 and VS2005 i guess...everyone talks
about gridview..

Stephen



Kerem OZMAN said:
Well you can use some UI tricks there but it depends on how you display your
dataset. For example, if your dataset has a table with a large field bound
to a GridView then you can use GridView's RowDataBound event and put some
code that visually trims your data. Here is a sample considering a GridView
which has some simple bound fields (place it in RowDataBound event handler
method of a GridView):
//Assuming your GridView displays two fields Title and FirstName
// in that order.

if(e.Row.RowType == DataControlRowType.DataRow)
{
//e is the GridRowEventArgs and Cells[1] is the FirstName field of a
//particular row. And assume any FirstName has minimum length of
//2 characters
e.Row.Cells[1].Text = e.Row.Cells[1].Text.Substring(0, 2);
// So you trimmed down your FirstName field to 2 characters.
}

It's not the best way but solution depends on the scenario you are working
on.
Stephen said:
Hi,

Suppose there is a column in the dataset that is a very large field (say
varchar(500)) and i want to display partial information with (....) so
that
the user can click on it to view for more.
(I dont want to truncate any info in the dataset...)
How can display partial information in a datagrid?

Thanks,
Stephen
 

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,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top