/// <summary> /// Cria uma linha para a grid. /// </summary> /// <param name="gridView"></param> /// <param name="rowIndex"></param> /// <param name="dataSourceIndex"></param> /// <param name="rowType"></param> /// <param name="rowState"></param> /// <returns></returns> public static System.Web.UI.WebControls.GridViewRow CreateRow( this System.Web.UI.WebControls.GridView gridView, int rowIndex, int dataSourceIndex, System.Web.UI.WebControls.DataControlRowType rowType, System.Web.UI.WebControls.DataControlRowState rowState) { var createRowMethod = typeof(System.Web.UI.WebControls.GridView).GetMethod("CreateRow", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] { typeof(int), typeof(int), typeof(System.Web.UI.WebControls.DataControlRowType), typeof(System.Web.UI.WebControls.DataControlRowState) }, null); try { return((System.Web.UI.WebControls.GridViewRow)createRowMethod.Invoke(gridView, new object[] { rowIndex, dataSourceIndex, rowType, rowState })); } catch (System.Reflection.TargetInvocationException ex) { throw ex.InnerException; } }
/// <summary> /// Cria uma linha na grid informada. /// </summary> /// <param name="gridView"></param> /// <param name="rowIndex"></param> /// <param name="dataSourceIndex"></param> /// <param name="rowType"></param> /// <param name="rowState"></param> /// <param name="dataBind"></param> /// <param name="dataItem"></param> /// <param name="fields"></param> /// <param name="rows"></param> /// <param name="pagedDataSource"></param> /// <returns></returns> public static System.Web.UI.WebControls.GridViewRow CreateRow( this System.Web.UI.WebControls.GridView gridView, int rowIndex, int dataSourceIndex, System.Web.UI.WebControls.DataControlRowType rowType, System.Web.UI.WebControls.DataControlRowState rowState, bool dataBind, object dataItem, System.Web.UI.WebControls.DataControlField[] fields, System.Web.UI.WebControls.TableRowCollection rows, System.Web.UI.WebControls.PagedDataSource pagedDataSource) { var createRowMethod2 = typeof(System.Web.UI.WebControls.GridView).GetMethod("CreateRow", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] { typeof(int), // rowIndex typeof(int), // dataSourceIndex typeof(System.Web.UI.WebControls.DataControlRowType), // rowType typeof(System.Web.UI.WebControls.DataControlRowState), // rowState typeof(bool), // dataBind typeof(object), // dataItem, typeof(System.Web.UI.WebControls.DataControlField[]), // fields typeof(System.Web.UI.WebControls.TableRowCollection), // rows typeof(System.Web.UI.WebControls.PagedDataSource) // pagedDataSource }, null); try { return((System.Web.UI.WebControls.GridViewRow)createRowMethod2.Invoke(gridView, new object[] { rowIndex, dataSourceIndex, rowType, rowState, dataBind, dataItem, fields, rows, pagedDataSource })); } catch (System.Reflection.TargetInvocationException ex) { throw ex.InnerException; } }