When i use AutoPostBack="true" on click of radio button, they are getting doubled and more ?

Posted by Iluvdotnetfunda under ASP.NET on 3/30/2012 | Points: 10 | Views : 1457 | Status : [Member] | Replies : 10
Hello Developers,

Good Day.
Here i have a issue when i use AutoPostBack="true" on select of radio button, they are getting double, if i select the radio button again they are increasing.

<asp:RadioButtonList ID="rblist" runat="server" OnSelectedIndexChanged="GetAnswerData1" AutoPostBack="true" />


my CS page code is

protected void GetAnswerData1(object sender, EventArgs e)
{
if (rblist.SelectedItem.Selected)
{
DataTable dTable = InterviewBAL.Load(prms);
DataRow row = dTable.Rows[0];
Label1.Text = row["CorrectObjectiveAnswer"].ToString();
Label2.Text = row["ObjectiveJustify"].ToString();
}
}

How to solve this problem, please help me.

Thanks&Regards
iluvdotnetfunda




Responses

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
have you used client script on radio button?

Thanks,
Rajni Shekhar

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Rajni.Shekhar,

I am getting you clearly.

Thanks.


Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hey Rajni,

Sorry yar, i am not getting you clearly.

Thanks

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
i m just asking, are you using javascript function/jquery to get answer? and autopostback="true". if so, then set it false.

Thanks,
Rajni Shekhar

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
i am not using any javascript or jquery, but i am using autopostback="true".
after changing auotpostback="false" also same thing is happening.

Thanks
iluvdotnetfunda

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: balajirnaukri-12656 on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
iluvdotnetfunda

There is nothing to do with autopostback because you are setting the autopostback to true only since you have written the server side coding.The problem might be since you are getting it value from the database.Can you put ur full coding page including the page load function that could be better to reseolve

Thanks and Regards
Balaji.R
ASP.NET Devloper
Solve-IT corp

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Balajirnaukri,


protected void Page_Load(object sender, EventArgs e)

{
// _userName = User.Identity.Name;

BindQuestion();
if (!IsPostBack)
{
dropCategory1.SelectedValue = "0"; // select all the values
PopulateDefaultValue(Int32.Parse(Resources.SiteConfiguration.Interview));
}
}


This is my pageload code.

Thanks.


Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ,

private void PopulateDefaultValue(int parentCatID)

{
CategoryBAL categoryBAL = new CategoryBAL();
try
{
dropCategory1.DataSource = categoryBAL.LoadAll(parentCatID, true);
dropCategory1.DataBind();
dropCategory1.Items.Insert(0, new ListItem("Please select"));
}
catch (Exception ee)
{
lblError.Text = ThrowError.LogAndThrowError(ee.ToString());
}
finally
{
categoryBAL = null;
}
}


Thanks

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
hi,
you need to debug your code, step by step by using f11. not getting exact idea what is happning.

or check below site, may help you

http://www.dotnetfunda.com/tutorials/controls/radiobuttonlist.aspx

Thanks,
Rajni Shekhar

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Iluvdotnetfunda on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hello Rajni,

Thanks for your feedback.

when i debug this i got a error by using Immediate Window.
?if (rblist.SelectedItem.Selected)

Invalid expression term 'if'


this is error i am getting.
Thanks

Iluvdotnetfunda, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response