how to add sorting function in repeater in asp 2.0?

前端 未结 3 1444
甜味超标
甜味超标 2021-02-06 17:10

I m using asp 2.0, I need an requirement for sorting the repeater control. I search over the Internet but i could nt find the correct solution. If anyone knows the answer please

3条回答
  •  梦谈多话
    2021-02-06 18:01

    Finally i got the Sorting output in Repeater Control.

    1.Maintaining the Static Variable;

    static int count = 0;
    

    2.In LinkButton click Event

    protected void lnkreq_name_click(object sender, EventArgs e)
    {
       count=Convert.ToInt32(ViewState["count"].ToString());
       ViewState["count"] = count;
       loadRepeater("REQUEST_NAME",count);
    }
    

    3.call the Function

    protected void loadRepeater(string reqname,int count)
    {
         //write the code to bind into Dataset
    
         DataView dv = ds.Tables[0].DefaultView;
         if (count  == 0)
         {
             dv.Sort = reqname + " asc";
             ViewState["count"] = 1;
          }
          else if (count == 1)
          {
              dv.Sort = reqname + " desc";
              ViewState["count"] = 0;
           }
    
           //then bind into repeater
    }
    

    4.In Repeater

    
     
    
    
    
    Request Name
    <%# Eval("REQUEST_NAME")%>

提交回复
热议问题