本文介绍了“grdview”这个名称在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码,当时访问母版页面网格视图
This is my code ,at the time to access the master page grid view
protected void ibtnOwner_Click(object sender, ImageClickEventArgs e)
{
GridView gvowner = (GridView)Master.FindControl("grdview");
Ownerbind();
}
public void Ownerbind()
{
MasterPage mp = this.Master;
GridView gvowner = (GridView)mp.FindControl("grdview");
String Bind = "SELECT [OwnId],[OwnerCode],[FirstName],[LastName],[MobileNo],[Email] FROM [WebCrm].[dbo].[tbl_Owner]";
SqlConnection con = new SqlConnection(cn.ConnectionStrings);
con.Open();
adp = new SqlDataAdapter(Bind, con);
DataSet ds = new DataSet();
adp.Fill(ds);
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
gvowner.DataSource = ds;
gvowner.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
gvowner.DataSource = ds;
gvowner.DataBind();
int columncount = gvowner.Rows[0].Cells.Count;
gvowner.Rows[0].Cells.Clear();
gvowner.Rows[0].Cells.Add(new TableCell());
gvowner.Rows[0].Cells[0].ColumnSpan = columncount;
gvowner.Rows[0].Cells[0].Text = "No Records Found";
}
}
protected void grdview_RowEditing(object sender, GridViewEditEventArgs e)
{
MasterPage mp = this.Master;
GridView gvowner = (GridView)mp.FindControl("grdview");
gvowner.EditIndex = e.NewEditIndex;
Ownerbind();
}
推荐答案
这篇关于“grdview”这个名称在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!