# [.net] Visual Studio 2005 seems limited

This topic is 4247 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey I noticed their dataview method seems really limited. You can't make the results display an url. Example: a guestbook that displays a link of each persons name like previewMessage.aspx?guestID=1. They're all static. Is there a way around this? Without programming the whole code yourself to display the data?

##### Share on other sites
Which version of it are you using?

There are a few:

Express
Standard
Professional
Enterprise architect etc, but I dont bother looking at those because...price range

##### Share on other sites
Team Suite Edition

##### Share on other sites
It sounds like you're describing a problem with ASP not a problem with visual studio. Visual Studio is not a language, it's a tool with which you can compile/link languages like C++/VB/.NET/etc

Are you asking how to display a url with ASP?

-me

##### Share on other sites
Perhaps your in need of the BoundField.HTMLEncode property? It's hard to get precisely what you're asking.

##### Share on other sites
If I understood You correctly, then this is how I do it in my datagrid:
aspx page:

' runat="server">Clicky

codebehind:

{
return String.Format("mypage.aspx?id={0}", id.ToString());
}

##### Share on other sites
If I understood You correctly, then this is how I do it in my datagrid:
aspx page:

_asp:TemplateColumn_
_ItemTemplate_
_/ItemTemplate_
_/asp:TemplateColumn_

codebehind:

{
return String.Format("mypage.aspx?id={0}", id.ToString());
}

##### Share on other sites

Or...

<itemtemplate>
_ a href='mypage.aspx?id= <%# (string)Eval("id") %>'_ Clicky _/a_
</itemtemplate>

The use of Eval in stead of Databinder.Eval is recommended in .net 2.0

Edo

##### Share on other sites
Quote:
 Original post by Anonymous PosterIf I understood You correctly, then this is how I do it in my datagrid:aspx page:_asp:TemplateColumn_ _ItemTemplate_ _asp:HyperLink ID="link" NavigateUrl='_%# GetLink(DataBinder.Eval(Container.DataItem, "id")) %_' runat="server"_Clicky_/asp:HyperLink_ _/ItemTemplate__/asp:TemplateColumn_codebehind:public string GetLink(object id){ return String.Format("mypage.aspx?id={0}", id.ToString());}

Are you trying to display the URL? If you are, then just set the 'Text' property of the asp:hyperlink to the same value as the 'NavigateUrl' property.

I.E.

<ItemTemplate>    <asp:HyperLink runat="server" id="linkName" NavigateUrl='<%# GetLink(DataBinder.Eval(Container.DataItem, "id")) %>' Text='<%# GetLink(DataBinder.Eval(Container.DataItem, "id")) %>'></ItemTemplate>

##### Share on other sites
O wow, I can't believe I was that blind...I feel extreamly stupid right now. I looked at the code again and there is the code blocks of <ItemTemplate> like someone said above. Thanks for all your help guys I really appreciate it and sorry for wasting your time. I should've looked closer...I'll get my eye's checked today :)

##### Share on other sites
real quick though, I tried to edit the template tag but it's not working out correctly, I tried the implementation of the block described above. Then I tried it this way:
            <asp:Label ID="guestIDLabel" runat="server" Text=' + ">" + <%# Eval("guestID") %> + ""'></asp:Label><br />

neither of the two worked they output parts of the code above. Thanks.

##### Share on other sites
nvm, I just had to edit the code a bit and I got it to work.

##### Share on other sites
Nvm I'm back again. This is is driving me up the wall. All I want to do is preform a simple task of putting a link that links to a page and supplies the damn id and the thing just simple is thumbing it's nose at me trying to p*** me off. I have this line:
            <asp:HyperLink runat="server" id="guestIDLabel" NavigateUrl='testpage.aspx?id=<%# Eval("guestID") %>' Text='<%# Eval ("guest_name") %>'></asp:HyperLink>

and it doesn't work. The link then reads (when in debugging mode) testpage.aspx?id=<%# Eval("guestID") %> and it's really getting me mad. It shouldn't be that hard to display a link or is ASP.NET that incompetant?

/rant

##### Share on other sites
I don't really see what's wrong with your code. It should work just fine the way you're doing it.
But if you don't manage to get it working you can try the following

Note: I'm not yet familier with ASP.NET 2.0. But I guess the DataView works similar to ASP.NET 1.1's DataGrid. So I will give you an example using a good old DataGrid

Then in the source page, attach an Eventhandler to the DataGrid's ItemDataBound Event (I will do this in VB.NET as I'm not a C# guy
[source lang=vb]Private Sub MyGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles MyGrid.ItemDataBoundIf e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then    dim MyLink as HyperLink//The next line uses the FindControl method to return the control which//corresponds to the control having id="MyLink" //and then casts it to a Hyperlink    MyLink = Ctype(e.Item.FindControl("MyLink"), Hyperlink)    MyLink.NavigateUrl = "Link goes here"End IfEnd Sub

I hope this helps you.
If .NET 2's DataView works differently then I'm sorry, but I can't help

Ooops, double post. Sorry. Can some moderator please remove the previous post?
[/Edit]

##### Share on other sites
This just goes to show you should pick proper subject lines. I thought it was actually a Visual Studio 2005 issue not a language issue. :-)

##### Share on other sites
By Supplying the ID, do you mean as in transferring the ID of the object over to the next page? if so, you may want to try session variables

##### Share on other sites
Try using DataBinder.Eval(Container.DataItem, "guestID") instead of just Eval("guestID")

##### Share on other sites
Quote:
 Original post by rpg_code_masterTry using DataBinder.Eval(Container.DataItem, "guestID") instead of just Eval("guestID")

Someone already suggested this. But it seems that best practice with .NET 2.0 would be to just use Eval("guestID"). Also it is certainly worth giving it a shot.

Anyway, I guess this post was rather pointless :)