Pages

Thursday, 22 March 2012

How to Find Grid View in Inner Grid View



 protected void grdCategory_RowDataBound(object sender, GridViewRowEventArgs e)
    {

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView row = (DataRowView)e.Row.DataItem;
            Label lblTitleId = (Label)e.Row.FindControl("lblId");
            //LinkButton lnkbtnCategory = (LinkButton)e.Row.FindControl("lbtnCategory");
            GridView grdSubCategory = (GridView)e.Row.FindControl("grdsubcat");
}
}
//Binding data to Inner Grid View Based On Main Grid View Id

protected void grdSubCategory_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView row = (DataRowView)e.Row.DataItem;
            LinkButton lnkbtnSubCategory = (LinkButton)e.Row.FindControl("lblproduct");
            lnkbtnSubCategory.Text = row["ProductName"].ToString();
            lnkbtnSubCategory.Attributes["SubCategoryId"] = row["ProductId"].ToString();
            lnkbtnSubCategory.Attributes["SubCategoryName"] = row["ProductName"].ToString();
        }
    }

No comments:

Post a Comment