Click here to Skip to main content
16,018,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code ,at the time to access the master page grid view

C#
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();

        }
Posted
Updated 20-Oct-15 20:52pm
v2
Comments
Krunal Rohit 21-Oct-15 2:53am    
Can you share Master Page code ?

-KR
Radhika20 21-Oct-15 3:18am    
This is a master page code

Connection cn = new Connection();
SqlDataAdapter adp;
appointment ap = new appointment();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}
protected void grdview_RowEditing(object sender, GridViewEditEventArgs e)
{
MasterPage mp = this.Master;
GridView gvowner = (GridView)mp.FindControl("grdview");
gvowner.EditIndex = e.NewEditIndex;
ap.Ownerbind();

}
Krunal Rohit 21-Oct-15 3:39am    
I meant .aspx code.

-KR
Radhika20 21-Oct-15 4:05am    
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
Maciej Los 25-Oct-15 5:14am    
Do not post such of code in comment! Use "Improve question" widget instead!

1 solution

check the id of the gridview control
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900