I am having trouble referencing a user control in edit mode..
the user control of course is 'gallery1' in the edit mode template of the first column.
here are the columns of the grid...
and the code behind follows...
Here is the code behind... I am having trouble with the edit mode only... I need to reference the control to populate it....
the insert and everything else is working fine.
Really would appreciate any help... i cant reference gallery in edit mode... the other modes have no issues.
the user control of course is 'gallery1' in the edit mode template of the first column.
here are the columns of the grid...
and the code behind follows...
<Columns> |
<telerik:GridTemplateColumn DataField="WallID" DataType="System.Int32" |
HeaderText="WallID" SortExpression="WallID" UniqueName="WallID"> |
<EditItemTemplate> |
<uc1:gallery ID="gallery1" runat="server" /> |
</EditItemTemplate> |
<ItemTemplate> |
<asp:Label ID="WallIDLabel" runat="server" Text='<%# Eval("WallID") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn DataField="Title" HeaderText="Title" |
SortExpression="Title" UniqueName="Title"> |
<ItemTemplate> |
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn DataField="Description" HeaderText="Description" |
SortExpression="Description" UniqueName="Description"> |
<ItemTemplate> |
<asp:Label ID="DescriptionLabel" runat="server" |
Text='<%# Eval("Description") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn DataField="Link" HeaderText="Link" |
SortExpression="Link" UniqueName="Link"> |
<ItemTemplate> |
<asp:Label ID="LinkLabel" runat="server" Text='<%# Eval("Link") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn DataField="Date" DataType="System.DateTime" |
HeaderText="Date" SortExpression="Date" UniqueName="Date"> |
<ItemTemplate> |
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
Here is the code behind... I am having trouble with the edit mode only... I need to reference the control to populate it....
the insert and everything else is working fine.
GridDataItem item; |
GridEditFormItem formitem; |
GridDataItem dataItem; |
string id; |
Wall w; |
ASP.uc_gallery_ascx gallery; |
string path = Server.MapPath("~/images/wall"); |
WebImage wi; |
if (e.Item is GridEditableItem) |
{ |
if (e.CommandName == "Edit") |
{ |
item = (GridDataItem)e.Item; |
//item = (GridDataItem)e.Item; |
gallery = (ASP.uc_gallery_ascx)item.FindControl("gallery1"); |
Label l = (Label)item.FindControl("WallIDLabel"); |
id = l.Text; |
w = DataRepository.WallProvider.GetByWallId(int.Parse(id)); |
gallery.Title = w.Title; |
gallery.Description = w.Description; |
gallery.DateEntered = (DateTime)w.Date; |
//gallery.Reference.SynchronizeFileSystem(true, Server.MapPath("~/images/wall"), w.WallId.ToString()); |
wi = WebImage.Load(Server.MapPath("~/images/wall/"), w.WallId.ToString()); |
gallery.Reference.Value = wi; |
} |
if (e.CommandName == "Update") |
{ |
formitem = (GridEditFormItem)e.Item; |
//item = (GridDataItem)e.Item; |
gallery = (ASP.uc_gallery_ascx)formitem["WallID"].FindControl("gallery1"); |
dataItem = formitem.ParentItem as GridDataItem; |
id = dataItem["WallID"].Text; |
w = DataRepository.WallProvider.GetByWallId(int.Parse(id)); |
w.Title = gallery.Title; |
w.Description = gallery.Description; |
w.Date = gallery.DateEntered; |
DataRepository.WallProvider.Save(w); |
gallery.Reference.SynchronizeFileSystem(true,path,w.WallId .ToString()); |
} |
if (e.CommandName == "PerformInsert") |
{ |
formitem = (GridEditFormItem)e.Item; |
//item = (GridDataItem)e.Item; |
gallery = (ASP.uc_gallery_ascx)formitem["WallID"].FindControl("gallery1"); |
dataItem = formitem.ParentItem as GridDataItem; |
//id = dataItem["WallID"].Text; |
w = new Wall(); |
w.Title = gallery.Title; |
w.Description = gallery.Description; |
w.Date = gallery.DateEntered; |
DataRepository.WallProvider.Save(w); |
gallery.Reference.SynchronizeFileSystem(true, Server.MapPath("~/images/wall"), w.WallId.ToString()); |
} |
if (e.CommandName == "Delete") |
{ |
item = (GridDataItem)e.Item; |
id = item.GetDataKeyValue("WallID").ToString(); |
w = DataRepository.WallProvider.GetByWallId(int.Parse(id)); |
wi = Radactive.WebControls.ILoad.WebImage.Load(path, w.WallId.ToString()); |
if (Radactive.WebControls.ILoad.WebImage.ExistsInFileSystem(path, w.WallId.ToString())) |
{ |
Radactive.WebControls.ILoad.WebImage.DeleteFromFileSystem(path, w.WallId.ToString()); |
} |
DataRepository.WallProvider.Delete(w); |
} |
Really would appreciate any help... i cant reference gallery in edit mode... the other modes have no issues.