添加控件的GridView细胞 [英] Adding Control to Gridview Cell
本文介绍了添加控件的GridView细胞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要添加上一定条件GridView的单元格的按钮。
我做RowDataBound事件以下
I want to add a button on GridView cell on certain condition. I did the following in RowDatabound event
if( i==0)
{
Button btn= new Button();
btn.Text = "view more";
e.Row.Cells[7].Controls.Add(btn);
}
在此执行,在这势必单元格中的文本将丢失,仅出现按钮。
我需要的按钮,单元格文本present已经沿。
When this executes, the text in the cell which is bound is lost and only the button appears. I need to have the button along with the cell text present already.
谁能帮我做这个?
由于提前
Can anyone please help me doing this? Thanks in Advance
推荐答案
它的解决方法,检查是否可以帮助你。
Its a workaround, Check if it helps you
您可以将现有的绑定列转换为 Linkbuton
,如果它是你的要求,是可行的。
you can convert your existing BoundColumn to Linkbuton
if it is feasible with your requirement.
if( i==0)
{
LinkButton lnkbtn = new LinkButton();
lnkbtn.Text = e.Row.Cells[7].Text;
// Create a command button and link it to your id
// lnkbtn.CommandArgument = e.Row.Cells[0].Text; --Your Id
// lnkbtn.CommandName = "NumClick";
// btn.Text = "view more";
e.Row.Cells[7].Controls.Add(lnkbtn);
}
这篇关于添加控件的GridView细胞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文