0

Finaly I decided to post this question here after many links followed with no success.

-I have a Repeater which retrieves data from a Database, showing records from it

-On each Item/record of repeater I have an asp LinkButton working as an ItemCommand. This one transports the record ID to cs side, do some stuff, and triggers a modal box with additional record information

-When Modal Box is triggered the Repeater is refreshed and I loose any filtering or sorting I made just before clicking on ItemCommand.

This should not happen, the table should keep exactly the same as before modal box popup.

Dont know if its relevant, but this sorting and ordering is made by javascript (I am using datatables.net).

I have tried to place the modal box inside an updatePanel but this one wont accept the LinkButton as a Trigger, I guess because it is inside Repeater. But I am not sure if this should be solved with an update panel or not. Any suggestions?

code from repeater item command

protected void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    if (e.CommandName == "showMoreInfo")
    {
         // do some stuff
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
    }
}

code from javascript that triggers modal box

<script>function openModal() { $('#myModal').modal('show'); }</script>
Rui
  • 3
  • 6
  • With a full postback you will always lose any client-side sorting/filtering so yes, the updatepanel is the way to go. Have you tried [this answer](https://stackoverflow.com/a/8717079/1145403) in which the link button is registered as async postback control? – Lennart Stoop Apr 06 '18 at 13:48
  • If i remember correctly you need to store filtering and sorting data into the control's viewstate in order to reuse them during refresh. But the fact you're using datatables.net seems to indicate that you need to store filtering and sorting client side and reapply them after update using javascript – Mumrah81 Apr 06 '18 at 13:52
  • @lennart I have been there before, but I tried again. The solution there is a little bit confusing to me, since i dont know where the "linkbutton1_click" came from nor what to do with it in my code. I removed that line and the postback issue was solved, but in other hand the modal box comes empty! Do I need to move the "do some stuff" from my code to the ItemCreatedEvent? – Rui Apr 06 '18 at 14:32
  • @RuiPedro the linkbutton_click is an event handler that is attached to the link button control inside the repeater. You should move your logic into this event handler. Regarding the modal dialog: you may need to put this in the update panel as well, which will allow the async postback to update its content. If you get stuck, feel free to update your initial question with additional code samples – Lennart Stoop Apr 06 '18 at 16:23
  • @lennart Yes I am stuck here, I think I should try from beginning and start a new post, Just one more question regarding this LinkButton issue: LinkButton_click is not being called from anywhere as far as I can see. I was expecting to see from aspx file some "onClik=LinkButton_click" but I dont see it. – Rui Apr 09 '18 at 09:43

0 Answers0