google了一个方法 TextBox t = (TextBox)sender;
RepeaterItem ri = (RepeaterItem)t.NamingContainer;
str = ((HiddenField)ri.FindControl("answer_tbx")).Value;
提示错误:无法将类型为“System.Web.UI.WebControls.TextBox”的对象强制转换为类型“System.Web.UI.WebControls.HiddenField”请问还有其他方法吗
RepeaterItem ri = (RepeaterItem)t.NamingContainer;
str = ((HiddenField)ri.FindControl("answer_tbx")).Value;
提示错误:无法将类型为“System.Web.UI.WebControls.TextBox”的对象强制转换为类型“System.Web.UI.WebControls.HiddenField”请问还有其他方法吗
foreach(repeaterItem item in rpt)
{
TextBox t=(TextBox)item.FindControl("answer_tbx");
}TextBox t = (TextBox)sender;//你这个肯定不行啦。
{
TextBox tb=(TextBox))rpDynamicNewsManage.Items[i].FindControl("single_Chk").text;
}
这样试试
TextBox tb=(TextBox))e.Items.FindControl("single_Chk");
((TextBox)ri.FindControl("answer_tbx")).Value;
要是找textbox的话:
str = ((TextBox)ri.FindControl("answer_tbx")).Text;
要不是:
str = ((HiddenField)ri.FindControl("隐藏控件名称")).Value;
或者 (ri.FindControl("answer_tbx") as TextBox).Value;
方案:前台放上一个hiddenId 作为服务器控件。
然后将值保存到hiddenId中后台获取就OK。
所以说lz得先将js搞懂,json,数组等搞懂