All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
"server"
AutoGenerateColumns
"false"
OnNeedDataSource
"RadGrid1_NeedDataSource"
OnUpdateCommand
"RadGrid1_UpdateCommand"
OnInsertCommand
"RadGrid1_InsertCommand"
>
MasterTableView
CommandItemDisplay
"Top"
DataKeyNames
"ID"
Columns
telerik:GridBoundColumn
DataField
UniqueName
HeaderText
</
"Name"
telerik:GridTemplateColumn
ItemTemplate
telerik:RadBinaryImage
"RadBinaryImage1"
DataValue='<%# Eval("Picture") == null ? null : ((System.Data.Linq.Binary) Eval("Picture")).ToArray() %>' />
EditItemTemplate
telerik:RadUpload
"RadUpload1"
telerik:GridEditCommandColumn
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
using
(DataClassesDataContext _context =
new
DataClassesDataContext())
RadGrid1.DataSource = _context.TablePictures.ToList();
}
RadGrid1_UpdateCommand(
sender, GridCommandEventArgs e)
GridEditableItem item = e.Item
as
GridEditableItem;
TablePicture tp = _context.TablePictures.Where(i => i.ID == Convert.ToInt32(item.GetDataKeyValue(
))).FirstOrDefault();
tp.Name = (item[
].Controls[0]
TextBox).Text;
RadUpload RadUpload1 = item.FindControl(
)
RadUpload;
if
(RadUpload1.UploadedFiles.Count > 0)
UploadedFile attachment = RadUpload1.UploadedFiles[0];
byte
[] attachmentBytes =
[attachment.InputStream.Length];
attachment.InputStream.Read(attachmentBytes, 0, attachmentBytes.Length);
tp.Picture = attachmentBytes;
_context.SubmitChanges();
RadGrid1_InsertCommand(
TablePicture tp =
TablePicture();
tp.ID = Convert.ToInt32((item[
TextBox).Text);
_context.TablePictures.InsertOnSubmit(tp);