Issue with Repeater in UserControl issue with kentico Page load called twice

born2achieve born2achieve asked on April 30, 2014 12:22

Hi,

Working in Asp.net 4.5 + Kentico CMS

I have Repeater in usercontrol and Inside the repeater i have 1 itemtemplate in which i have ImageButton on it. Also i am handling the Click event on the Imagebutton using ItemCommand of the Repeater. when i click the image button it fires the item_command on the codebehind which is fine. But if i use !Ispostback on page load to stop loading the databind event again which is in pageload, it's not firing the Item_Command Event.

If i remove the !Ispostback from my page it's doing the pageload event againt which has calling my databind methoad and then it calls the Item_commans event. Wondering is this kentico issue or usercontrol problem?

Any suggestion please

Recent Answers


Joshua Adams answered on May 1, 2014 11:50

Can you not move the itemcommand event handler outside of the !ispostback check?

0 votesVote for this answer Mark as a Correct answer

born2achieve born2achieve answered on May 1, 2014 12:45

Hi Joshuva,

Already the item_command event sits outside of the page_load event only. Any suggestions please

structure:

protected void Page_Load(object sender, EventArgs e) { Databind() } protected void rptImages_ItemDataBound(object sender, RepeaterItemEventArgs e) { //code }

if i use !ispostback on the pageload like below,

protected void Page_Load(object sender, EventArgs e)
{
 if(!Ispostback)
 {
 Databind();
 }
}

The item_command event not firing. This must be kentico issues because i tested this with non kentico environment and it woks fine.

any suggestions please

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 1, 2014 15:53

Are you using the User Control webpart to display the user control? Or have you created a webpart and used a standard asp.net repeater? Or have you used some other method?

0 votesVote for this answer Mark as a Correct answer

born2achieve born2achieve answered on May 1, 2014 16:01

I have created Usercontrol and i dropped the repeater in the usercontrol. I probably suspect the the repeater's Viewstate is getting lossed thats why it's not working if i put my databind method on if(!ispostback) { Databind(); }

i tried to enable the view state page level still it's not working. My motive is if the hit the iamge button oon the repeater it should fire the item_command event which out hitting the Databind method on the pageload.

any help please

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on May 12, 2014 15:39

Are you using the cms:repeater or a normal asp.net repeater? Where do you connect the datasource to the repeater?

0 votesVote for this answer Mark as a Correct answer

Sébastien Grandjean answered on August 20, 2014 08:54

I have the same problem. Does anyone has a solution? The problem arises with a normal asp.net repeater and a CMSRepeater. The datasource is connected in the PageLoad.

Thank you.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.