Im a beginner at this asp.net dynamic data and have just been completing a few tutorials on youtube etc...
I was hoping maybe now to create a datagrid, (1) which binds labels to fields (exmaple) <asp:label runat=”server” ID=”abc” Text=’<%# Bind(“fieldname”) %>’>
(2) Also, where one of the columns had a hyperlink, which would bind to an external URL...so something instead of <asp:HyperLink ID="ChangePassword" runat="server" NavigateUrl="http://www.google.com" Target="_blank">Visit Google</asp:HyperLink>
I could have NavigateUrl=’http://bbcnews/<%# Bind(“id”) %>'which would then produce bbcnews/23, bbcnews/24, bbcnews/25 etc...
Could someone please point me in the right direction of where I can get a tutorial on this. Theres plenty of tutorials out there but I can't seem to find any relating to what I want to do.
Thanks
datagrid, label, hyperlink, binding
Page 1 of 14 Replies - 1863 Views - Last Post: 11 January 2013 - 08:21 PM
Replies To: datagrid, label, hyperlink, binding
#2
Re: datagrid, label, hyperlink, binding
Posted 10 January 2013 - 12:25 PM
SO i've created a datagrid and linked it to one of my tables from my db. I then want to add a hyperlink which should bind to a column from the table
This isn't working can someone advise what I am doing wrong? I have 2 columns in my table, Name and External_Hyperlink, each row (inside the external_hyerplink column) contains the extension to a url so depending on which row was clicked i would get www.google.com/extension1, or www.google.com/extension2 etc.... but dont think I am anywhere near this, please help.
Thanks
<asp:DataGrid ID="DataGrid1" runat="server" DataSourceID="SqlDataSource1">
</asp:DataGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:holidaysConnectionString %>"
SelectCommand="SELECT [Name], [External_Link] FROM [Person]">
</asp:SqlDataSource>
<asp:HyperLink ID="hyperlink" runat="server" NavigateUrl='http://www.google.com/<%# Bind("External_Link")%>' Target="_blank">Visit Google</asp:HyperLink>
This isn't working can someone advise what I am doing wrong? I have 2 columns in my table, Name and External_Hyperlink, each row (inside the external_hyerplink column) contains the extension to a url so depending on which row was clicked i would get www.google.com/extension1, or www.google.com/extension2 etc.... but dont think I am anywhere near this, please help.
Thanks
This post has been edited by Xna4life: 10 January 2013 - 12:33 PM
#3
Re: datagrid, label, hyperlink, binding
Posted 10 January 2013 - 12:30 PM
Let's not open duplicate topics, m'kay?
#4
Re: datagrid, label, hyperlink, binding
Posted 10 January 2013 - 12:34 PM
#5
Re: datagrid, label, hyperlink, binding
Posted 11 January 2013 - 08:21 PM
If your wanting that custom binding in the datagrid you create a TemplateColumn - which means setting AutoGenerateColumns to false and making BoundColumns for simple binding.
<asp:TemplateColumn HeaderText="Dose">
<ItemTemplate >
<asp:HyperLink ID="hyperlink" runat="server" NavigateUrl='http://www.google.com/<%# Bind("External_Link")%>' Target="_blank">Visit Google</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote







|