Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am trying to fetch value of textbox and dropdownlist inside a repeater on button click event
so i write code like this :-

C#
foreach (RepeaterItem item in rptMember.Items)
        {
 TextBox txtamount = (TextBox)item.FindControl("txtfund1");
                if (txtamount != null)
                {
                    amount = Convert.ToString(txtamount.Text);
                }
 else
            {
                DropDownList ddlTot = (DropDownList)item.FindControl("ddlTotal");
                if (ddlTot != null)
                {
                    tot = ddlTot.SelectedItem.ToString();
                }
            }
       }


but its fetching right value of textbox when first time loop run and fetch right value/selected value of dropdown when runs second time....
can anyone tell me how to do this...
Posted
Updated 16-May-13 0:38am
v2

if (ddlTot != null)
{
tot = ddlTot.SelectedItem.ToString();
}

Check this condition i think it will be

tot = ddlTot.SelectedItem.value.ToString();
 
Share this answer
 
i put a break in textbox condition...
C#
if (hfRid.Value == "0")
            {
                TextBox txtamount = (TextBox)item.FindControl("txtfund1");
                if (txtamount != null)
                {
                    amount = Convert.ToString(txtamount.Text);
                }
                break;
            }
            else
            {
                DropDownList ddlTot = (DropDownList)item.FindControl("ddlTotal");
                if (ddlTot != null)
                {
                    tot = ddlTot.SelectedItem.Value.ToString();
                }
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900