Gridview中的模板字段 [英] Template field in Gridview

查看:78
本文介绍了Gridview中的模板字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何在模板字段GridView,Asp.Net中检查2个条件.取决于应在gridview中显示图像按钮

帮助pl

问候,
Praveen

Hello all,

How to check 2 conditions in the template field, GridView, Asp.Net. Depending upon that the image button should be displayed in the gridview

Help pl

Regards,
Praveen

推荐答案

U可以在gridview中使用RowDataBound事件
尝试n了解以下示例:


受保护的void gv1_RowDataBound(object sender,GridViewRowEventArgs e)
{
试试
{
如果(e.Row.RowType == DataControlRowType.DataRow)
{
字符串状态= DataBinder.Eval(e.Row.DataItem,"Status").ToString();
如果(status.Trim()==显示")
{
((LinkLink)e.Row.FindControl("lbtnView")).Visible = true;
((LinkLink)e.Row.FindControl("lbtnClose")).Visible = true;

}
否则,如果(status.Trim()=="Close")
{
((LinkLink)e.Row.FindControl("lbtnView")).Visible = true;
((LinkBut​​ton)e.Row.FindControl("lbtnClose")).Visible = false;
lblRemarks.Visible = true;
labelRemark.Visible = true;
}

}
}
U can use RowDataBound Event in gridview
Try n Understand the following example:


protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string status = DataBinder.Eval(e.Row.DataItem, "Status").ToString();
if (status.Trim() == "Show")
{
((LinkButton)e.Row.FindControl("lbtnView")).Visible = true;
((LinkButton)e.Row.FindControl("lbtnClose")).Visible = true;

}
else if (status.Trim() == "Close")
{
((LinkButton)e.Row.FindControl("lbtnView")).Visible = true;
((LinkButton)e.Row.FindControl("lbtnClose")).Visible = false;
lblRemarks.Visible = true;
labelRemark.Visible = true;
}

}
}


,您可以使用行数据绑定在gridview中显示图像按钮.
如果您要针对您要检查的内容专门发布一些相关代码.
you can use row databound for displaying the image button in gridview.
if you want specific post some relevant code against what you want to check..


http://www.dotnetfunda.com/tutorials/controls/gridview.aspx


请检查此链接....很遗憾,您可以解决您的问题..
http://www.dotnetfunda.com/tutorials/controls/gridview.aspx


Please check this link....unfortunality you can get solution of your questation..


这篇关于Gridview中的模板字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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