This is a migrated thread and some comments may be shown as answers.

[Solved] Trying to fire Item command from User Control Edit Form

5 Answers 308 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Goksun
Top achievements
Rank 1
Goksun asked on 12 Feb 2008, 07:58 PM
Hi All,

I am trying to find an answer to my problem and couldn't find anything in the forums. Here's what I'm trying to do.

I have a RadGrid and the edit form is a user control. I am adding some link buttons dynamically at run time to the edit form in Grid's Item Created event. These link buttons will be used to download different files. Here's my code to create the dynamic link button.

LinkButton lnkScriptFile = new LinkButton();

lnkScriptFile.ID =

"lnkScriptFile1";

lnkScriptFile.CommandName =

"DownloadAttachment";

lnkScriptFile.Text =

"Attachment " + (i + 1) + ": " + dtr["FileName"].ToString() + dtr["Extension"].ToString();

lnkScriptFile.CommandArgument = dtr[

"StageFileId"].ToString();

lnkScriptFile.OnClientClick =

String.Format(@"{0}.__doPostBack(""{1}"",""{2}"");", RadAjaxManager1.ClientID, lnkScriptFile.UniqueID, lnkScriptFile.CommandArgument);

pnlScriptFiles.Controls.Add(lnkScriptFile);

I am adding OnClientClick event handler to do a real postback when the button is clicked. But I also need to invoke ItemCommand event of the grid. How can I do that?

Thanks
Goksun

5 Answers, 1 is accepted

Sort by
0
Goksun
Top achievements
Rank 1
answered on 12 Feb 2008, 08:23 PM
I forgot to add that, if I add a static LinkButton on the control, ItemCommand event is fired. I just need to find out how to add the event handler.

Thanks
Goksun
0
Rosen
Telerik team
answered on 14 Feb 2008, 11:31 AM
Hi Goksun,

Are you experience this behavior with Mozilla browser? Can you please try setting the RadGrid control as postback Target through passing its id as first parameters to the doPostBack function. I have attached a simple project that demonstrates this approach.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Goksun
Top achievements
Rank 1
answered on 15 Feb 2008, 08:31 PM
No, I am using IE 7. Anyway, I've changed my approach and added ResponseStart and ResponseEnd client events to the code and enable/disable AJAX based on the id of the control which fired the event. Now, dynamic link buttons fire ItemCommand.

But now, I have another problem. When I click on the link button, I have a file dialog. I have save/open/cancel options and my file is saved/opened based on the choice. And I end the Response to finish my file operation. (Http.Current.Response.End())

However, this doesn't end the response for the grid. So whatever I do afterwards, I always get the ItemCommand. The Status Bar displays "Loading".

How can I end the response (or expire it) of the grid page?

Thanks
Goksun
0
Accepted
Rosen
Telerik team
answered on 18 Feb 2008, 12:34 PM
Hello Goksun,

I'm not sure what your scenario is, so can you please send us (attached to formal support ticket) a small working project in which this behavior can be observed. This will let us understand the problem in details and provide you with more specific answer.

Meanwhile you can review this demo example on how to upload files with ajax.

Kind regards,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Goksun
Top achievements
Rank 1
answered on 20 Feb 2008, 01:19 AM
Hi Rosen,

Never mind, I've solved my problem by replacing Link buttons with hyperlinks. I don't need to open a support ticket for this. Thanks for your help.

Goksun
Tags
Grid
Asked by
Goksun
Top achievements
Rank 1
Answers by
Goksun
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or