or
Dear All,
Can someone please help me with AsyncUpload control inside RadGrid since I am really new with Telerik controls.
I have a DB table with column names as:
RecordID Name AttachmentPath
1 Name1 ~/Attachments/File123_1.pdf
2 Name2 ~/Attachments/File125_2.pdf
Below are what I did:
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
TargetFolder
=
"~/Attachments"
OnFileUploaded
=
"RadAsyncUpload1_FileUploaded1"
>
</
telerik:RadAsyncUpload
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
3. Fired the OnFileUploaded event to upload control in a path. (Works Perfect)
protected
void
RadAsyncUpload1_FileUploaded1(
object
sender, FileUploadedEventArgs e)
{
string
rootPath =
"~/Attachments/"
;
string
path = Server.MapPath(createSubFolder(rootPath));
e.File.SaveAs(path + e.File.GetName());
}
Below are what I want:
Point to be noted, I want only one file to be associated/attached per record.
Thanks In Advance,
Fawad Surosh
Please advice.
Thanks,
Soo
public enum MyEnum
{
Value1,
Value2,
Value3,
Value4,
Value5
}
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadButton1_Click(object sender, EventArgs e)
{
if (RadGrid1.MasterTableView.FilterExpression == "")
{
RadGrid1.MasterTableView.FilterExpression = "([Value] = '" + MyEnum.Value1 + "')";
}
else
{
RadGrid1.MasterTableView.FilterExpression = "";
}
RadGrid1.Rebind();
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("Key");
table.Columns.Add("Value");
for (int i = 1; i < 6; i++)
{
table.Rows.Add("Key" + i.ToString(), "Value" + i.ToString());
}
RadGrid1.DataSource = table;
}
}
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
//Put your JavaScript code here.
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
div
>
<
h2
>Test Grid filtering</
h2
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
onclick
=
"RadButton1_Click"
Text
=
"RadButton"
>
</
telerik:RadButton
>
</
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
EnableLinqExpression
=
"false"
AllowFilteringByColumn
=
"true"
onneeddatasource
=
"RadGrid1_NeedDataSource"
Width
=
"500px"
>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>