您的位置:首页 > 其它

获取GridView的EmptyDataTemplate中的控件

2010-09-23 20:55 435 查看
方法一:

protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
if (gv.Rows.Count > 0)
{
try
{
string thing = ((TextBox)gv.FooterRow.FindControl("txtFthings")).Text;
int result = dam.InsertwGCDSJ(thing, Convert.ToInt32(this.DropDownList1.SelectedValue), 0);
if (result > 0)
{
this.gv.FooterRow.Visible = false;
BindData();
}
else
{ message_Show("添加失败!"); }

}
catch { }
}
else
{
Table gvTable = ((Table)gv.Controls[0]);
string netThing = ((TextBox)gvTable.Rows[0].FindControl("txtNewThing")).Text;

}

}

方法二:

protected void GridViewSearchResult_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.EmptyDataRow)
        {
            ((Label)(e.Row.FindControl("LabelKeyword"))).Text = Request["keyword"];
        }
    }

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: