国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - ASP.NET教程 - asp.net下無法循環(huán)綁定投票的標(biāo)題和選項的解決方法

asp.net下無法循環(huán)綁定投票的標(biāo)題和選項的解決方法

2019-09-10 11:46asp.net教程網(wǎng) ASP.NET教程

asp.net下無法循環(huán)綁定投票的標(biāo)題和選項與無法循環(huán)獲得用戶的選擇的解決方法。

問題:1,無法循環(huán)綁定投票的標(biāo)題和選項 
解決方法: 在Repeater綁定中添加ItemDataBound事件,選項用RadioButtonList綁定,附源代碼: 
Default頁,源頁面 

復(fù)制代碼代碼如下:


<div> 
廣大網(wǎng)友對保障房建設(shè)相關(guān)問題調(diào)查<br /> 
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound"> 
<ItemTemplate> 
<table> 
<tr> 
<td colspan="3"> 
<b> 
<%# Eval("t_timu")%> 
<asp:Literal ID="Literal1" Text='<%# Eval("t_id")%>' runat="server"></asp:Literal> 

</b> 
</td> 
</tr> 
<tr> 
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"> 
</asp:RadioButtonList> 
</tr> 
</table> 
</ItemTemplate> 
</asp:Repeater> 
<br /> 
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="提交" />  
<asp:Button ID="Button2" runat="server" Text="查看結(jié)果" OnClick="Button2_Click" /> 
</div> 



對應(yīng)的cs頁: 

復(fù)制代碼代碼如下:


protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 

Literal Literal1 = (Literal)e.Item.FindControl("Literal1"); 
RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("RadioButtonList1"); 
RadioButtonList1.DataSource = dcw_toupiao_M.dcw_toupiao_getxuanxian(Convert.ToInt32(Literal1.Text)); 
RadioButtonList1.DataTextField = "x_name"; 
RadioButtonList1.DataValueField = "x_id"; 
RadioButtonList1.DataBind(); 


問題2: 無法循環(huán)獲得用戶的選擇 
解決方法: 先循環(huán)Repeater控件的Item獲得RadioButtonList控件,循環(huán)檢測是否為選中狀態(tài),,如果是則拼接到一個字符串中, 
再把題目的編號獲得拼接起來,循環(huán)添加,附源代碼: 

Default的cs頁: 

復(fù)制代碼代碼如下:


protected void Button1_Click(object sender, EventArgs e) 

string zifu = ""; 
string Pid = ""; 
int tiaoshu = 5; 
foreach (RepeaterItem iemt in Repeater1.Items) 

RadioButtonList rbtn = iemt.FindControl("RadioButtonList1") as RadioButtonList; 
try 

if (rbtn.SelectedItem.Selected) 

zifu += rbtn.SelectedItem.Value + ","; 

Literal Literal1 = (Literal)iemt.FindControl("Literal1"); //e.Item.FindControl(""); 
if (Literal1.Text != "") 

Pid += Literal1.Text + ","; 


catch (Exception ex) 



string[] xid = null; 
xid = zifu.TrimEnd(',').Split(','); 
string[] pid = null; 
pid = Pid.TrimEnd(',').Split(','); 
if (dcw_toupiao_M.dcw_toupiao_Insert(xid, pid, tiaoshu)) 

this.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "<script>alert('投票成功!謝謝參與')</script>"); 

else 

this.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "<script>alert('請完成選擇')</script>"); 


DAL頁: 

復(fù)制代碼代碼如下:


public static bool dcw_toupiao_Insert(string[] xid, string[] pid, int tiaoshu) 

bool flag = false; 
for (int i = 0; i < pid.Length; i++) 

SqlParameter[] prm = new SqlParameter[2]; 
prm[0] = new SqlParameter("@xid", Int32.Parse(xid[i])); 
prm[1] = new SqlParameter("@pid", Int32.Parse(pid[i])); 
if (dcw_toupiao_M.dcw_toupiao_gettcount(Convert.ToInt32(xid[i]), Convert.ToInt32(pid[i]))) 

flag = _dc_toupiao_DB.SqlHelper.ExeucteNonQuery("sm_dcw_toupiao_Insert", CommandType.StoredProcedure, prm) > 0; 



return flag; 


所掌握的技巧: 
JavaScript跳轉(zhuǎn): 
this.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "<script>alert('投票成功!謝謝參與')</script>"); 
兩種獲得控件的方法: 
Literal Literal1 = (Literal)e.Item.FindControl("Literal1"); 
Literal Literal1 = e.Item.FindControl("Literal1") as Literal;

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久久久国产精品免费 | 中国一级毛片 | av在线精品| 另类五月 | 欧美黄网站 | 日韩在线精品 | 91久久精品国产91久久 | av网站免费观看 | 亚洲精品久久久一区二区三区 | 欧美天堂在线观看 | 国产在线一区二区 | 久久99操 | 久久九| 中文字幕在线免费视频 | 国产精品日韩在线观看 | 欧美在线网站 | 亚洲视频区 | 国产精品久久久久久久久免费桃花 | 日韩在线免费 | 四虎影视 | 日韩有码在线观看 | 久久久久久久久久久免费视频 | 国产精品网站在线看 | 在线干 | 国产精品福利视频 | 一区二区中文字幕 | 九色视频网站 | 一级毛片免费版 | 久久99精品国产自在现线 | 一级a性色生活片毛片 | 黄色短片免费看 | 亚洲精品1区 | 中文字幕一区二区三区日韩精品 | 国产毛片精品 | 日韩午夜 | 国产电影一区二区 | 亚洲美女在线视频 | 黄片毛片| 精品美女 | 国产精品69久久久久水密桃 | 色接久久|