Reputation:
I am binding a datagrid with a table. There is one datagrid column as--
<asp:BoundColumn DataField="Title" HeaderText="Title">
The 'Title' field in the table returns the value-- "http://bhu453526d:1234/Item/results.aspx?searchId=, test 123" but i want to bind only the value "test 123".
Please suggest how to do this? Thanks in advance.
Upvotes: 0
Views: 96
Reputation: 6453
This is probably how I would do it. Instead of a BoundColumn
, use a TemplateColumn
:
<asp:TemplateColumn HeaderText="Title">
<ItemTemplate><%#GetID(Eval("Title"))%></ItemTemplate>
</asp:TemplateColumn>
And in your code-behind page:
protected static string GetID(object Title)
{
string[] queryString = Title.ToString().Split('?');
// Only if you're sure you want the value of the first element in the QueryString
return queryString[1].Split('=')[1];
}
Upvotes: 2