[.net] Visual Studio 2005 seems limited

Started by
17 comments, last by RizMan 17 years, 10 months ago
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 :)
Advertisement
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.
nvm, I just had to edit the code a bit and I got it to work.
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
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

In your aspx page, in the ItemTemplate, give an ID to your Hyperlink control (e.g. id="MyLink").

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

[Edit]
Ooops, double post. Sorry. Can some moderator please remove the previous post?
[/Edit]
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. :-)

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

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
We'll bring your children up in the classic English manner, by making them learn latin, and beating them half to death in a single sex environment.
Try using DataBinder.Eval(Container.DataItem, "guestID") instead of just Eval("guestID")
Quote:Original post by rpg_code_master
Try 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 :)

This topic is closed to new replies.

Advertisement