Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid query

Status
Not open for further replies.

xloop

Programmer
Nov 12, 2001
86
GB
Hi

Working with ASP.NET

I'm interogating each value in a datagrid with the ItemCreated event.

What i'm trying to do is, search for a specified string in a column, if it equals that then set the appropriate DataNavigateURL property, something like this:

DataGrid dg = (DataGrid)sender;
HyperLinkColumn hlk = null;
string str = (string)DataBinder.Eval(e.Item.DataItem, "Status");
if (str != null)
{
string strStatus = str.Trim();
if (strStatus == "FREE")
{
hlk = (HyperLinkColumn)dg.Columns[1];
hlk.DataNavigateUrlField = "RoomID";
hlk.DataNavigateUrlFormatString = "BookRoom.aspx?RoomID={0}";

This works fine, however

1) If i set this for just one row all of them become underlined, is there a way to just underline certain ones?

2) Can i have more than one querystring, ie i would like to do something like this;


hlk.DataNavigateUrlField = "RoomID,BookedBy";
hlk.DataNavigateUrlFormatString = "BookRoom.aspx?RoomID={0}&BookedBy={1}";

But that doesn't work.

Help appreciated.
 
If i set this for just one row all of them become underlined

I've no idea what "them" you refer to there. Please specify.

As for your second question, you can't do formatting like that. :-( Although it would seem like something that might be available in the future, doesn't it?

For now, just do string concatenation to wind up w/ the same effect.

lnk.url = "somePage.aspx?var1="+val1+"&var2="&val2;
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Yep, i've managed to bodge it.

Cheers

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top