Gridview正在排序,但无法使用递增的下降箭头添加gridview ..要添加的方式? [英] Gridview is sorting but unable to add gridview with ascending descending arrows..how to add?

查看:57
本文介绍了Gridview正在排序,但无法使用递增的下降箭头添加gridview ..要添加的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dono我错了,我已经采取了一个事件进行排序,这是我的排序gridview的代码它工作正常,但我无法添加箭头到girdview,上面我已经尝试过但它没有添加我的箭头,我如何添加箭头?

i已尝试过一些文章,但我无法添加上升和下降的箭头,gridview在点击标题行时排序,但需要显示给用户他可以根据上升箭头和下降箭头进行排序......



protected void grdInformation_Sorting(object sender,GridViewSortEventArgs e)

{

if(CurrentSortExpression == e.SortExpression.ToString())

{

if(CurrentSortDirection ==asc)

CurrentSortDirection =desc;

else

CurrentSortDirection =asc;

}

其他

{

CurrentSortExpression = e.SortExpression.ToString();

CurrentSortDirection =asc;

}



if(e.SortExpression.Trim()== this.SortField)

{

这个。 sortDirection =(this.sortDirection ==DESC? ASC:DESC);

}

else

{

this.sortDirection =ASC ;

}

ViewState [SortDirection] = this.sortDirection;

this.SortField = e.SortExpression;



Bindinfo(GetInformation(ddlStatus.SelectedValue,ddlGroups.SelectedValue));

}





请帮忙??



我尝试了什么:



这是我用箭头添加gridview的代码..

Gridview按升序和降序排序,但我无法添加箭头。



protected void grdInformation_RowCreated(object sender,GridViewRowEventArgs e)

{

if(e.Row!= null&& e.Row.RowType == DataControlRowType.Header)

{



foreach(e.Row中的TableCell单元格)。细胞)

{



if(cell.HasControls())

{



LinkBut​​ton button = cell.Controls [0] as LinkBut​​ton;

HtmlGenericControl gv = new HtmlGenericControl(div);



标签lnkName = new Label();

lnkName.Text = button.Text;







if(button!= null)

{



Image imageSort = new Image();

imageSort.ImageUrl =〜/ images / asc.png;





if(grdInformation.SortExpression == button.CommandArgument)

{



if(grdInformation.SortDirection == SortDirection.Ascending )

{

imageSort.ImageUrl =〜/ images / desc.png;

}

else

{

imageSort.ImageUrl =〜/ images / asc.png;

}

} < br $>


gv.Controls.Add(lnkName);



gv.Controls.Add(imageSort);



button.Controls.Add(gv);





}



}



}



}







}

}

}

Dono where i am going wrong , I have took an event for sorting , this is my code for sorting gridview it is working finee, but i am unable to add arrows to the girdview , the above i have tried but its not adding me arrows, how do i add arrows ??
i have tried some articles but i am unable to add arrows with ascending and descending , gridview is sorting when clicking on header rows , but need to display to the user that he can sort based on ascending arrows and descending arrows ...

protected void grdInformation_Sorting(object sender, GridViewSortEventArgs e)
{
if (CurrentSortExpression == e.SortExpression.ToString())
{
if (CurrentSortDirection == "asc")
CurrentSortDirection = "desc";
else
CurrentSortDirection = "asc";
}
else
{
CurrentSortExpression = e.SortExpression.ToString();
CurrentSortDirection = "asc";
}

if (e.SortExpression.Trim() == this.SortField)
{
this.sortDirection = (this.sortDirection == "DESC" ? "ASC" : "DESC");
}
else
{
this.sortDirection = "ASC";
}
ViewState["SortDirection"] = this.sortDirection;
this.SortField = e.SortExpression;

Bindinfo(GetInformation(ddlStatus.SelectedValue, ddlGroups.SelectedValue));
}


Please help ??

What I have tried:

This is my code for adding gridview with arrows..
Gridview is sorting by ascending and descending but i am unable to add arrows.

protected void grdInformation_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row != null && e.Row.RowType == DataControlRowType.Header)
{

foreach (TableCell cell in e.Row.Cells)
{

if (cell.HasControls())
{

LinkButton button = cell.Controls[0] as LinkButton;
HtmlGenericControl gv = new HtmlGenericControl("div");

Label lnkName = new Label();
lnkName.Text = button.Text;



if (button != null)
{

Image imageSort = new Image();
imageSort.ImageUrl = "~/images/asc.png";


if (grdInformation.SortExpression == button.CommandArgument)
{

if (grdInformation.SortDirection == SortDirection.Ascending)
{
imageSort.ImageUrl = "~/images/desc.png";
}
else
{
imageSort.ImageUrl = "~/images/asc.png";
}
}

gv.Controls.Add(lnkName);

gv.Controls.Add(imageSort);

button.Controls.Add(gv);


}

}

}

}



}
}
}

推荐答案

试试这个

ASP.NET GridView按图像排序 [ ^ ]


这篇关于Gridview正在排序,但无法使用递增的下降箭头添加gridview ..要添加的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆