locked
DataList RRS feed

  • Question

  • User1932525027 posted

    Hey guys,

    I am currently working on a job posting section for a website. I have created two tables, one for job types (ie Administrative, Mechanic etc) and another table to list the job information (duties, posted date etc), and three pages. One for the job type, a second page for the jobs listed of that type, and finally the third page, a full job description.

    Here's where I am running into trouble. I've created a DataList, which displays my data in 3 columns so the candidate can select the job type. I have added code so they become active links, but the links are not filtering. They are loading the second page will all the results in the table.

    I am obviously missing a query somewhere. Any help would be appreciated.

    Thanks!

     

    Friday, September 9, 2011 2:09 PM

Answers

All replies

  • User-26034409 posted

    Hello!

    add CommandName and CommandArgument attributes to the links under DataList and 

    write code under DataList ItemCommand Event..to filter the result w.r.t the selected link under DataList

    <ItemTemplate>
      <asp:ImagButton ID="img1" runat="server"
              CommandName="m1" CommandArgument='<%# Eval("ImgView")%>'
              ImageUrl='<%# Eval("ImgView")%>'
       </asp:ImageButton>
    </ItemTemplate>

    then under the ItemCommand event of DataList...you can write your own logic using CommandArgument like this

    void DataList1_ItemCommand(Object sender, EventArgs args)
    {
          if(e.CommandName == "m1")
          {
              Response.Redirect("page2.aspx? arg="+e.CommandArgument.ToString());
          }
    }
    Friday, September 9, 2011 2:35 PM
  • User1932525027 posted

    Thanks.

    By following these 2 tutorials:

    http://msdn.microsoft.com/en-us/library/aa581776.aspx

    http://www.asp.net/data-access/tutorials/master-detail-filtering-across-two-pages-cs

    I was able to figure out what i was missing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 9, 2011 4:37 PM