參考:http://blog.xuite.net/yan.kee/CSharp/14844624?ref=rel
解法如下
C# 加上下面的CODE就OK了
public override void VerifyRenderingInServerForm(Control control)
{
}
下面為過濾物件的Function 在
this.ClearControls(dg); //這邊叫用會過濾掉物件資料
dg.RenderControl(oHtmlTextWriter);
private void ClearControls(Control control)
{
for (int i = control.Controls.Count - 1; i >= 0; i--)
{
ClearControls(control.Controls[i]);
}if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
try
{
literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control, null);
}
catch
{}
control.Parent.Controls.Remove(control);
}else
if (control.GetType().GetProperty("Text") != null)
{
LiteralControl literal = new LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control, null);
control.Parent.Controls.Remove(control);
}
}
return;
}
留言列表