Reputation:
This is continued from link button in repeater to pass session variable but nothing happens when I try to click the link button I added to my repeater. Here is what I have
<asp:Repeater ID="rptList" runat="server"
EnableViewState="false"
OnItemCommand="rptList_ItemCommand"
DataSourceID="SqlDataSource3">
<ItemTemplate>
<div>
<p>
<b>Title: </b> <asp:LinkButton ID="lbnCookieVar" CommandName="click" CommandArgument='<%# Eval("Job_Title")%>' Text='<%# Eval("Job_Title")%>' runat="server" /> <br />
<b>Status: </b><%# Eval("Status")%><br />
<b>Department: </b><%# Eval("Department")%><br />
<b>Date Position Available: </b><%# Eval("Date_Position_Available")%><br />
</p>
</div>
</ItemTemplate>
</asp:Repeater>
Code Behind:
protected void rptList_ItemCommand(object sender, CommandEventArgs e)
{
if (e.CommandName == "click")
{
Session["Data"] = e.CommandArgument.ToString();
Response.Redirect("default.aspx");
}
}
I apologize for the new post but for whatever reason I was not allowed post on the last one kept saying "User not alllowed to comment to this post"
Upvotes: 0
Views: 150
Reputation: 10604
What and where is the code to bind the repeater. Most often in these cases, the data that fills the repeater has not been bound on the postback. Check that it is.
Upvotes: 0
Reputation: 28970
1 You have mismatch
CommandText -> CommandName in your aspx
try with this code
<asp:LinkButton ID="lbnCookieVar" CommandName="click" CommandArgument='<%# Eval("Job_Title")%>' Text='<%# Eval("Job_Title")%>' runat="server" /> <br />
2 Add OnItemCommand
in your repeater
Upvotes: 2