I have a datalist that bound to a database where now the label is change to a link button
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("username") %>'>
</asp:LinkButton>
.....some other datalist item
</ItemTemplate>
</asp:DataList>
For this case I wanted the link button to fired up a new page where the Eval(“username”) value is passed to the new page.
I’m thinking about passing it using session such as ….
string any_variable ;
session["Picked_username_from_datalist"] = any_variable ;
response.redirect("newpage.aspx");
so that the variable that I’m going to pass using session can be manipulated.
But my problem is I have no idea how to assign the Text='<%# Eval(“username”) %> to the variable any_variable …..
~~ the assigned value for the variable is depends on the text of the databind that binded to the database …. for example … 1st linkbutton text is username1 , and the 2nd is username2 and so on based on my SQL select command …..
I need the selected Text='<%# Eval(“username”) %> so that I can manipulate the information to display another databind control based on the value.
Can anybody help me?
you can use onitemcommand=”DataList1_ItemCommand” event of DataList
server side code is