code behind

I would like to carry the value of SelectedPartNo  from code behind to aspx
and i have id2=<%=SelectedPartNo%> and it is not working now.

How can I fix it?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SelectedId = String.Empty
        SelectedId = Request.QueryString("id")
        Dim SelectedPartNo = String.Empty
        If (SelectedId <> "") Then
            SelectedPartNo = SingleItem(SelectedId, "1")
        End If
End Sub

<asp:DataList RepeatColumns="4" Font-Bold="true" 
        ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Width="630px">
            <br /><a href=Default.aspx?PL=Sitemap&id=<%# Eval("CATEGORY")%>&id2=<%=SelectedPartNo%>><font color="blue" size="2"><%# Eval("CATEGORY") %></font></a><br />

Open in new window

Who is Participating?
HainKurtConnect With a Mentor Sr. System AnalystCommented:
Dim SelectedPartNo = String.Empty
public SelectedPartNo = String.Empty

and move it to line 2
HainKurtSr. System AnalystCommented:

<a href="Default.aspx?PL=Sitemap&id=<%# Eval("CATEGORY")%>&id2=<%=SelectedPartNo%>">

what is not working? any error message? what is rendered html?
HainKurtSr. System AnalystCommented:
make sure SelectedPartNo is defined as public/friend
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.