Hi, I think what you need is something like this:
<ItemTemplate> <li> <asp:LinkButton Text='<%# Container.DataItem( "CategoryName" ) %>' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "LinkName") %>' Runat="Server" /> </ItemTemplate> This way, you can make the connection between CategoryName and LinkName using the LinkButton. Hope this will help you! S.Putinelu On Mon, 15 Apr 2002 14:18:32 +0100, Ricardo Figueira <[EMAIL PROTECTED]> wrote: >Friends, > >Sorry, but my last email is more or less confusing some people :P .... the >only think i want to know is this : > >With that code, if you run it it will work just fine (sqlserver), i want to >associeted the number link (control) to some links , like, >first link redirect to "path\index.aspx?mn=1&link=1", the second redirect to >"path\index.aspx?mn=1&link=2" ..... > >Let me explain what i want do to... > >If you run the page you get something like this (some links) : > > * Beverages > * Condiments > * Confections > * Dairy Products > * Grains/Cereals > * Meat/Poultry > * Produce > * Seafood > >The code i have put in the email, capture the name of link, that was press, >that are stored in one Database (in this example are the Northwind Database) > >IF i add on the Database the field "LinkName" , for example : > >On the database : > >CategoryName | LinkName >--------------------------- >Beverages | path\index.aspx?mn=1&link=1 >Condiments | path\index.aspx?mn=1&link=2 >Confections | path\index.aspx?mn=1&link=3 >Dairy Products | path\index.aspx?mn=1&link=4 >Grains/Cereals | path\index.aspx?mn=1&link=5 >Meat/Poultry | path\index.aspx?mn=1&link=6 >Produce | path\index.aspx?mn=1&link=7 >Seafood | path\index.aspx?mn=1&link=8 > > >And in the code we change this line : > >SqlCommand( "Select CategoryName From Categories", conNorthwind ) > >to > >SqlCommand( "Select CategoryName, LinkName From Categories", conNorthwind ) > > >How can i associate the link that was press to the right "LinkName" ? > >Note that the code give me the name os the links (CategoryName) ! > >Example: If i press on the first link, the code will capture the name >"Beverages". >Ok, BUT how i can associate the link that was press to the right "LinkName" >that are on the Database ? > >Note: >I dont want to associed the name to the link like: > >Example : > >If blCategory.Text="Beverages" then > strReturnURL= "path\index.aspx?mn=1&link=1" > Response.Redirect( strReturnURL ) >end if > >If i do, something, like that, i will have to change the code always i >change the (CategoryName or LinkName). > >I what use the ButtonLink, because : >1 - he made "postback" >2 - He use POST method > >And I can capture the values of parametrs and choose the link to redirect, >something, like this: > >ex: >dim StrMenu as string >dim StrLink as string >dim StrUrl as string > >StrMenu = request.form("mn") >StrLink = request.form("link") > >if stmenu = "1" and link="1" then > StrUrl= "index.aspx?mn=1&link=1" >end if > >etc... etc > > >Finaly..... the main question is : > >If i have in the Database the fields (CategoryName, LinkName) : > >On the database : > >CategoryName | LinkName >--------------------------- >Beverages | path\index.aspx?mn=1&link=1 >Condiments | path\index.aspx?mn=1&link=2 >.... >.... >... > >How can i associate the link that was press to the right LinkName using the >LinkButton ? > > >I will apreciated all help :P >Thanks !! > >here is the full file code : > >******************************* ><%@ Import Namespace="System.Data.SqlClient" %> > ><Script Runat="Server"> > >Sub Page_Load > If Not IsPostBack Then > Dim conNorthwind As SqlConnection > Dim cmdSelect As SqlCommand > Dim dtrCategories As SqlDataReader > > conNorthwind = New SqlConnection( >"Server=localhost;UID=sa;PWD=;Database=Northwind" ) > cmdSelect = New SqlCommand( "Select CategoryName From Categories", >conNorthwind ) > conNorthwind.Open() > dtrCategories = cmdSelect.ExecuteReader() > > rptCategories.DataSource = dtrCategories > rptCategories.DataBind() > > dtrCategories.Close() > conNorthwind.Close() > End If >End Sub > >Sub Button_Click( s As Object, e As RepeaterCommandEventArgs ) > Dim lbtnSelected As LinkButton > > lbtnSelected = e.Item.Controls( 1 ) > lblCategory.Text = "You selected " & lbtnSelected.Text >End Sub > ></Script> > ><html> ><head><title>LinkButtonList.aspx</title></head> ><body> ><form Runat="Server"> > ><asp:Repeater > ID="rptCategories" > OnItemCommand="Button_Click" > Runat="Server"> > ><ItemTemplate> > <li> > <asp:LinkButton > Text='<%# Container.DataItem( "CategoryName" ) %>' > Runat="Server" /> ></ItemTemplate> > ></asp:Repeater> > ><p> ><asp:Label > ID="lblCategory" > Runat="Server" /> > ></form> ></body> ></html> > >*************************** > >Best regards, > >Ricardo Figueira (RBFIGUEIRA) >Moderador Lista PontoNetPT >http://groups.yahoo.com/group/PontoNetPT >*** PORTUGAL :P ********** > >You can read messages from the DOTNET archive, unsubscribe from DOTNET, or >subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.