在asp.net中获取转发器内的下拉列表和文本框的值 [英] fetching values of dropdownlist and text box inside repeater in asp.net
本文介绍了在asp.net中获取转发器内的下拉列表和文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在按钮点击事件中获取转发器内的文本框和下拉列表的值
所以我写这样的代码: -
i am trying to fetch value of textbox and dropdownlist inside a repeater on button click event
so i write code like this :-
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...
推荐答案
if(ddlTot!= null)
{
tot = ddlTot.SelectedItem.ToString();
}
检查这个条件我认为这将是
tot = ddlTot.SelectedItem.value.ToString();
if (ddlTot != null)
{
tot = ddlTot.SelectedItem.ToString();
}
Check this condition i think it will be
tot = ddlTot.SelectedItem.value.ToString();
我在文本框条件中休息了...
i put a break in textbox condition...
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();
}
}
这篇关于在asp.net中获取转发器内的下拉列表和文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文