imran azam

imran azam

  • NA
  • 98
  • 12.9k

I want to validate radiobuttonlist based on Item.

Feb 11 2016 1:24 AM
I have one datalist inside there is one radiobuttonlist and  item binding from database. in radiobuttonlist there are three Item binded Approved,N/A and Rejected.
for image please go to this link...   http://stackoverflow.com/questions/35313639/how-can-we-validate-radiobuttonlist-inside-datalist-based-on-item 
so what  do i want when user click on Update button and if they are going to approve then all fileds(suppose there are 10 record binding) should be mandatory to checked. 
I want to validate all Approve Item on Button click not N/A or Reject.Please suggest me how can i achive this task. ..Here is some code that i have written it's working fine but also asking for Reject button when i  click on second record and leaving first as null.
int sum = 0;
foreach (DataListItem item in dtLstRejection.Items)
{
RadioButtonList rdlReasoncodeType ((RadioButtonList)item.FindControl("rdlReasonType"));
System.Web.UI.WebControls.Label lbldlmsg = (Label)item.FindControl("lbldlmsg");
{
if (rdlReasoncodeType.SelectedIndex == 0|| rdlReasoncodeType1.SelectedIndex== -1)
{
if (rdlReasoncodeType1.SelectedItem == null)
{
if (sum == 0)
{
lbldlmsg.Text = "*Approve fields are mandatory to check";
return; }}}}
else
{
sum++;
lbldlmsg.Text = "";
}
lbldlmsg.Text = "";
}}

Answers (3)