Need to manipulate a column before displaying

P

Paul D. Fox

I am setting a datagrid's Datasource to a Dataset returned from a Web Service. However, I need to manipulate one of the columns. The column being returned is a relative URL, so I need to prefix the column's data with the first part of the URL to make it an Absolute URL. How can I do this so the datagrid column displays this? I'm thinking something like...
dgDatagrid.DataSource = ListAllDocuments.PTDocRetrieve(txtPTFolderID.Text)
dgDatagrid.DataBind()

'********************************************************
'strPTReturnURI will have the value http://machineName/server.pt"
'********************************************************

'I need to prefix the column with a string from strItem, this of course doesn't work, but you get the idea
strItem = strPTReturnURI & dgDatagrid.Items(6).DataItem
dgDatagrid.Items(6).DataItem() = strItem

Paul
 
S

Scott Mitchell [MVP]

Paul said:
I am setting a datagrid's Datasource to a Dataset returned from a Web
Service. However, I need to manipulate one of the columns. The column
being returned is a relative URL, so I need to prefix the column's data
with the first part of the URL to make it an Absolute URL. How can I do
this so the datagrid column displays this?

You have a couple of options. One option is to use an ItemTemplate and
call a helper method, passing in the URL field and manipulating it in
your method. You can see this method described in more detail here:
http://datawebcontrols.com/faqs/CustomizingAppearance/CustomizeColumnValue.shtml

You could also modify the value in the ItemDataBound event. More info at:
http://datawebcontrols.com/faqs/CustomizingAppearance/ConditionalFormatting.shtml


hth
 
P

Paul D. Fox

Thanks Scott, I already figured out the first approach. However, your
second approach is pretty cool.

Paul

Scott Mitchell said:
Paul said:
I am setting a datagrid's Datasource to a Dataset returned from a Web
Service. However, I need to manipulate one of the columns. The column
being returned is a relative URL, so I need to prefix the column's data
with the first part of the URL to make it an Absolute URL. How can I do
this so the datagrid column displays this?

You have a couple of options. One option is to use an ItemTemplate and
call a helper method, passing in the URL field and manipulating it in your
method. You can see this method described in more detail here:
http://datawebcontrols.com/faqs/CustomizingAppearance/CustomizeColumnValue.shtml

You could also modify the value in the ItemDataBound event. More info at:
http://datawebcontrols.com/faqs/CustomizingAppearance/ConditionalFormatting.shtml


hth


--

Scott Mitchell [ASP.NET MVP]
(e-mail address removed)
http://www.4GuysFromRolla.com/ScottMitchell
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top