Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Unable to pass values to a Hyperlink Colu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Unable to pass values to a Hyperlink Colu

 Post Reply Post Reply Page  12>
Author
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Topic: Unable to pass values to a Hyperlink Colu
    Posted: 07 October 2004 at 7:11pm

Hey guys, I am using BoundColumn and HyperlinkColumns to create a datagrid.

I have two bound Columns that provides me two values.

I am trying to pass those two values to the Hyperlinkcolumn to pass it as a querystring into a model window.

Code:

 For i = 0 To myDataSet.Tables(0).Columns.Count - 1

                 Dim dgColumn As New BoundColumn

                 Select Case myDataSet.Tables(0).Columns(i).ColumnName

                     Case "id"
                         dgColumn.HeaderText = "Id"
                         dgColumn.DataField = myDataSet.Tables(0).Columns(i).ColumnName
                         dgWorkflow.Columns.Add(dgColumn)

                     Case "name"
                         dgColumn.HeaderText = "Name"
                         dgColumn.DataField = myDataSet.Tables(0).Columns(i).ColumnName
                         dgWorkflow.Columns.Add(dgColumn)

                 End Select
Next

Dim dgHColumn As New HyperlinkColumn
dgHColumn.Text = "View"
dgHColumn.NavigateUrl = "Javascript: alert('value1/value2')

How can i have each value in in row to be passed into the link.

Thanks,

Shrini

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2004 at 11:26am
Could you explain what you want to do a bit more? I don't know what you want
Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2004 at 2:49pm

To simply put, I want a third column in the datagrid that willt ake the values of the ID and Name and pass as a querystring.

Any help will be appreciated.

Thanks,
Shrini

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2004 at 3:08pm
ahh, ok. Convert it to a template column in property builder, then go into HTML view and change the markup inside the third template column to something like:


<a href='mypage.aspx?ID=<%# Databinder.Eval(Container.DataItem, "ID") %>&Name=<%# Databinder.Eval(Container.DataItem, "Name") %>'>View details</a>

Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2004 at 8:53pm

I understand that Mart.

My problem is I have to write it programatically, and I am having extreme problems. I do have HTML view option on what I am writing on. Everything is straight code behind. Is it possible you can show me a simple example on how to do that code behind.

Thanks again,

Shrini

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2004 at 3:57am
Sure, in your code behind just put:


Public Function GetLink(ByVal ID As Integer, ByVal Name As String) As String
Return String.Format("mypage.aspx?ID={0}&Name={1}", ID, Name)
End Function


then in design view have this:


<a href='<%# GetLink(Databinder.Eval(Container.DataItem, "ID"), Databinder.Eval(Container.DataItem, "Name")) %>'>View details</a>

Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2004 at 1:46pm

I appologize not explaining it right the first time. I should be shot.

I understand using the function.

My thing is, I am doing everything code behind. I simply don't have an optioin use the HTML View to add do the following.

<asp:TemplateColumn>
     <ItemTemplate>
         <%# DataBinder.Eval(Container.DataItem, "id") %>
         <%# DataBinder.Eval(Container.DataItem, "name") %>
     </ItemTemplate>
</asp:TemplateColumn>

I have to actually write the whole thing in the code behind and populate it in to the datagrid. Again no access to HTML view for me to insert ASP controls. All Controls are beng generated from code behind.

I need to do the following and what I marked in red is giving me an error saying dataitem is not a member of "System.ComponentModel.Container". If I use a # sign then it says expression expected.

Dim myCol as New TemplateColumn
myCol.ItemTemplate = GetLink(DataBinder.Eval(Container.DataItem, "id"),DataBinder.Eval(Container.DataItem, "name"))

Public Function GetLink(ByVal ID As Integer, ByVal Name As String) As String
     Return String.Format("mypage.aspx?ID={0}&Name={1}", ID, Name)
End Function

This gets solved, my biggest headch is over. Becasue of this problem I had to change my code to old ASP style and loop through each record, formating it into a table and then assigning it into a label. Lets not forget finding a rope next to me and hanging myself doing it in that manner rather an simply doing it with a dg.

What I understand is I have to Use ITemplate to get this working if I am going to do this programmatically...

I can't find any proper VB reference on ITemplate to get it going. Not even a simple example...



Edited by vshriniwasan
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2004 at 2:28pm
Usually any type beginning with an I is an interface, I don't know off hand but I'm sure ITemplate is an interface. So you need to type the following:


Public Class MyTemplate
Implements ITemplate

End Class


After you press <Enter> after the implements line VS should insert some Properties, Subs etc... You need to fill these, then you can use MyCol.ItemTemplate = MyTemplate. I will write you an example if I have time
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.