protected
void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
this.RadGrid1.DataSource = ImagesLibraryDB.GetLibraries(localeId, prefLanguage, memberId, portalId);
this.tableViewOrders.DataSource = ImagesLibraryDB.GetImageForLibrary(portalId, memberId, Convert.ToInt32("LibraryID"].ToString()));
}
Also I'm using
RadGrid1.MasterTableView.EditFormSettings.UserControlName =
"~/BackOffice/ImagesLibrary/Libraries.ascx";
for edit or create a new item, how can I make the update botton invisible if I'm adding a new record.private void DefineGridStructure()
{
RadGrid1.ID =
"RadGrid1";
RadGrid1.Width =
Unit.Percentage(98);
RadGrid1.AllowPaging =
true;
RadGrid1.AllowSorting =
true;
RadGrid1.PagerStyle.Mode =
GridPagerMode.NumericPages;
RadGrid1.AutoGenerateColumns =
false;
//RadGrid1.EnableAJAX = true;
RadGrid1.GridLines =
GridLines.None;
RadGrid1.ShowStatusBar =
true;
RadGrid1.AllowAutomaticDeletes =
true;
RadGrid1.AllowAutomaticInserts =
false;
RadGrid1.AllowAutomaticUpdates =
true;
RadGrid1.MasterTableView.DataKeyNames =
new string[] { "LibraryID" };
RadGrid1.MasterTableView.AutoGenerateColumns =
false;
RadGrid1.PageIndexChanged +=
new Telerik.Web.UI.GridPageChangedEventHandler(this.RadGrid1_PageIndexChanged);
RadGrid1.NeedDataSource +=
new Telerik.Web.UI.GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource);
RadGrid1.ItemDataBound +=
new Telerik.Web.UI.GridItemEventHandler(this.RadGrid1_ItemDataBound);
RadGrid1.ItemCommand +=
new GridCommandEventHandler(RadGrid1_ItemCommand);
GridBoundColumn boundColumn;
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"Title";
boundColumn.HeaderText = title;
boundColumn.SortExpression =
"Title";
boundColumn.UniqueName =
"Title";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"Description";
boundColumn.HeaderText = description;
boundColumn.SortExpression =
"Description";
boundColumn.UniqueName =
"Description";
boundColumn.MaxLength = 500;
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"CreatedDt";
boundColumn.HeaderText = createddt;
boundColumn.SortExpression =
"CreatedDt";
boundColumn.UniqueName =
"CreatedDt";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"UpdatedDt";
boundColumn.HeaderText = updateddt;
boundColumn.SortExpression =
"UpdatedDt";
boundColumn.UniqueName =
"UpdatedDt";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
GridButtonColumn buttoncolumn;
buttoncolumn =
new GridButtonColumn();
buttoncolumn.HeaderText = restore;
buttoncolumn.Text = restore;
buttoncolumn.ConfirmText = strconfirmdelete;
buttoncolumn.ButtonType =
GridButtonColumnType.ImageButton;
buttoncolumn.ImageUrl =
"~/Images/grid/refresh.gif";
buttoncolumn.CommandName =
"Restore";
RadGrid1.MasterTableView.Columns.Add(buttoncolumn);
buttoncolumn =
new GridButtonColumn();
buttoncolumn.HeaderText = delete;
buttoncolumn.Text = delete;
buttoncolumn.ConfirmText = strconfirmdelete;
buttoncolumn.ButtonType =
GridButtonColumnType.ImageButton;
buttoncolumn.ImageUrl =
"~/Images/grid/delete.gif";
buttoncolumn.CommandName =
"Delete";
RadGrid1.MasterTableView.Columns.Add(buttoncolumn);
tableViewOrders.DataKeyNames =
new string[] { "ImageID" };
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField =
"LibraryID";
relationFields.DetailKeyField =
"LibraryID";
tableViewOrders.ParentTableRelation.Add(relationFields);
RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders);
string veditColumnName = "GroupID";
string vcArg = "";
int vcount = -1;
string vtype = "Image";
GridTemplateColumn veditColumn = new GridTemplateColumn();
veditColumn.ItemTemplate =
new editTemplate(veditColumnName, vcArg, vcount, vtype);
RadGrid1.MasterTableView.Columns.Add(veditColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"Title";
boundColumn.HeaderText = title;
boundColumn.SortExpression =
"Title";
boundColumn.UniqueName =
"Title";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"Description";
boundColumn.HeaderText = description;
boundColumn.SortExpression =
"Description";
boundColumn.UniqueName =
"Description";
boundColumn.MaxLength = 500;
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"CreatedDt";
boundColumn.HeaderText = createddt;
boundColumn.SortExpression =
"CreatedDt";
boundColumn.UniqueName =
"CreatedDt";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn =
new GridBoundColumn();
boundColumn.DataField =
"UpdatedDt";
boundColumn.HeaderText = updateddt;
boundColumn.SortExpression =
"UpdatedDt";
boundColumn.UniqueName =
"UpdatedDt";
RadGrid1.MasterTableView.Columns.Add(boundColumn);
//Add the RadGrid instance to the controls
this.PlaceHolder1.Controls.Add(RadGrid1);
}