开发者

querystring picking up last row in table and not specified row. vb.net

i have created a table with 2 fields in vb.net as follows -

            Do While SqlDR.Read()
                TR = New HtmlTableRow

                TD = New HtmlTableCell
                TD.InnerHtml = SqlDR("name")
                TR.Cells.Add(TD)

                TB.Rows.Add(TR)
            Loop
        SqlDR.Close()

Data looks like this -

Nam开发者_JAVA技巧e 
Jimi
Jonathan
Paulie

How do i put a hyperlink on the name cell, so when i click on a specific name it will goto next page with that name?


You could just use a <asp:HyperLink> to be your hyperlink, but it tends to be bad form to use hyperlinks as post backs.

You should probably use the LinkButton's CommandName and CommandArgument properties. Where the command name is whatever you want and command argument is the id for that particular row.

Then you can create a Command event handler to redirect to the appropriate page.

See: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.commandname.aspx

Or you could just make the NavigateURL of the hyperlink just be:

NavigateURL = "profiles.aspx?name_id=" & l.ID


This backwards from how asp.net is supposed to work. You want to re-think everything and do something more like this in your markup instead:

<asp:SqlDataSource Id="somedatasource" runat="serveR" ConnectionString="..." SelectCommand="..." />

<table><tr><th>Names</th></tr>
<asp:Repeater id="somerepeater" runat="server" DataSourceID="somedatasource">
    <ItemTemplate><tr><td><a href="page?name=Eval("name")">Eval("name")</a></td></tr></ItemTemplate>
</asp:Repeater>
</table>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜