Hello,
This is what I need to achieve.
I have a radgrid. I have few columns. In one of the columns (I have a combobox here), I will select a user. I have a column in this grid, that has a file attachment in it. Another column in this grid is a button - "SendMail". On Click of this buttton, I have to send the mail to the user whom I have selected from the dropdown with this attachment. Please help me how I can do this.
Thanks and Regards,
Deepika Karanth
This is what I need to achieve.
I have a radgrid. I have few columns. In one of the columns (I have a combobox here), I will select a user. I have a column in this grid, that has a file attachment in it. Another column in this grid is a button - "SendMail". On Click of this buttton, I have to send the mail to the user whom I have selected from the dropdown with this attachment. Please help me how I can do this.
Thanks and Regards,
Deepika Karanth
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 13 Feb 2012, 07:25 AM
Hello,
Take a look into the following forum thread which discussed the same.
Open Email and attach grid as pdf or Excel
Thanks,
Princy.
Take a look into the following forum thread which discussed the same.
Open Email and attach grid as pdf or Excel
Thanks,
Princy.
0
Deepika
Top achievements
Rank 1
answered on 13 Feb 2012, 07:50 AM
Hi Princy,
I have this file saved in my database. It is not in a local location. Please help me to solve this scenario.
Thanks and Regards,
Deepika Karanth
I have this file saved in my database. It is not in a local location. Please help me to solve this scenario.
Thanks and Regards,
Deepika Karanth
0
Hi Deepika,
Can you please elaborate a bit more on what part related to the grid functionality do you have problems with achieving. In general you can:
1) Set a CommandName to the button that you want to click for the print.
2) Wire the ItemCommand event and capture the case where e.CommandName equals the custom command name of the button.
3) In this case e.Item will be GridDataItem which you can use to access the needed data related to the user.
From this point on it is up to you to decide how to handle your data and the print itself. Let us know in case there is anything unclear in relation to RadGrid's API or features.
Kind regards,
Tsvetina
the Telerik team
Can you please elaborate a bit more on what part related to the grid functionality do you have problems with achieving. In general you can:
1) Set a CommandName to the button that you want to click for the print.
2) Wire the ItemCommand event and capture the case where e.CommandName equals the custom command name of the button.
3) In this case e.Item will be GridDataItem which you can use to access the needed data related to the user.
From this point on it is up to you to decide how to handle your data and the print itself. Let us know in case there is anything unclear in relation to RadGrid's API or features.
Kind regards,
Tsvetina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Deepika
Top achievements
Rank 1
answered on 02 Mar 2012, 07:50 AM
Hi,
I can download the attachment using the below code.
But, I want to attach this file as an attachment to the MailMessage Object.
So basically, I want to get the FileNm to have the file that is represented by the filename in the upper code.
Please suggest how I can implement this.
Thanks and Regards,
Deepika Karanth
I can download the attachment using the below code.
DataSet dsFileData = oBLL.GetFileData(fileID);
byte[] bFileData= (byte[])dsFileData.Tables[0].Rows[0]["FileData"];
filename = dsFileData.Tables[0].Rows[0][
"FileName"].ToString();
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
Response.BinaryWrite(bFileData);
Response.End();
But, I want to attach this file as an attachment to the MailMessage Object.
string
fileNm=string.Empty;
MailMessage oMailMsg = new MailMessage();
oMailMsg.Attachments.Add(new Attachment(fileNm));
So basically, I want to get the FileNm to have the file that is represented by the filename in the upper code.
Please suggest how I can implement this.
Thanks and Regards,
Deepika Karanth
0
Hi Deepika,
In case this code is in ItemCommand and you have the fileNm field in your grid's DataSource, you could use the following code:
You need to add fileNm to the DataKeyNames of the MasterTableView to be able to access it as shown above.
Greetings,
Tsvetina
the Telerik team
In case this code is in ItemCommand and you have the fileNm field in your grid's DataSource, you could use the following code:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"SendMail"
)
{
GridDataItem item = e.Item
as
GridDataItem;
string
id = item.GetDataKeyValue(
"fileNm"
).ToString();
}
}
You need to add fileNm to the DataKeyNames of the MasterTableView to be able to access it as shown above.
Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.