How to avoid multiple times calling a method

Posted by Self-Innovator under ASP.NET on 12/14/2012 | Points: 10 | Views : 1033 | Status : [Member] | Replies : 2
Hi all,
I have an checkboxlist control i need to avoid to calling a method redundantly...Please check my code

Page Design:
<asp:CheckBoxList ID="chkContactDetails" runat="server" 
RepeatDirection="Horizontal" AutoPostBack="True"
onselectedindexchanged="chkContactDetails_SelectedIndexChanged">
<asp:ListItem>Contact Details</asp:ListItem>
<asp:ListItem>Horoscope Details</asp:ListItem>
<asp:ListItem>Kundali Details</asp:ListItem>
</asp:CheckBoxList>



Code.cs file

checkboxlist_selection changed EVENT
for (int i = 0; i < chkContactDetails.Items.Count; i++)
{
if (chkContactDetails.Items[i].Selected == true)
{
if (chkContactDetails.Items[i].Text == "Contact Details")
{
tblContactDetails.Visible = true;
GetContactDetails(CustId);
}
else if (chkContactDetails.Items[i].Text == "Horoscope Details")
{
tblHoroscopeDetails.Visible = true;
GetHoroscopeDetails(CustId);
}
else if (chkContactDetails.Items[i].Text == "Kundali Details")
{
GetKundaliDetails(CustId);
}
}
}

when ever i am selecting the last check box kundali details and then i am selecting and deselecting the other two check boxes at every time it was getting to database and once again calling the function how to avoid this. I need to call the method only once after selection of a specific item..

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Dotnetrajanikanth on: 12/14/2012 [Member] Starter | Points: 25

Up
0
Down
Check whether you have used autopostback.

____________
www.flickr.com/photos/psdesigner/

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 12/15/2012 [Member] Bronze | Points: 25

Up
0
Down
if i used auto postback inside a tetxboxchange event

Those methods (inside the textchange) are not triggering find any other soln...DotnetRajinikanth

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response