0

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"

Community
  • 1
  • 1

2 Answers2

2

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

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
  • ok...I made the fixes you suggested...the new code is edited in the original post –  Aug 07 '12 at 18:47
0

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.

Josh
  • 10,352
  • 12
  • 58
  • 109
  • its bound...it reads the data perfectly...I just cant get the link button to fire –  Aug 07 '12 at 18:49