- 1 //用查询得的数据集进行绑定
- 2
- if (dt.Rows.Count > 0) 3 {
- 4 //绑定
- 5 this.gv_InfoFromSendModule.DataSource = dt;
- 6 this.gv_InfoFromSendModule.DataBind();
- 7 //确定按钮显示
- 8 this.btn_OK.Visible = true;
- 9 this.txthid_RowCount.Text = dt.Rows.Count.ToString();
- 10
- }
- 11 //GridView的RowDataBound
- 12 protected void gv_InfoFromSendModule_RowDataBound(object sender, GridViewRowEventArgs e) 13 {
- 14
- if (e.Row.RowIndex < 0) 15
- return;
- 16 e.Row.Attributes.Add("onclick", "radButton('" + e.Row.RowIndex.ToString() + "','" + e.Row.Cells[1].Text.Trim() + "');");
- 17 //RadioButton rad = (RadioButton)e.Row.Cells[0].FindControl("rad_Select");
- 18 //rad.Attributes.Add("onclick", "radButton('"+e.Row.RowIndex.ToString()+"','"+ e.Row.Cells[1].Text.Trim()+"');");
- 19
- }
- 20 //行上所绑定的JS
- 21
- function radButton(rowIndex, rowGUID) 22 {
- 23 //gv_InfoFromSendModule$ctl02$rad_Select
- 24
- var rowCount = parseInt(document.all.txthid_RowCount.value) + 2;
- 25
- for (var i = 2; i) 26 {
- 27
- var tmpName;
- 28
- if (i < 10) 29 {
- 30 tmpName = "gv_InfoFromSendModule$ctl0" + i + "$rad_Select";
- 31
- }
- 32
- else 33 {
- 34 tmpName = "gv_InfoFromSendModule$ctl" + i + "$rad_Select";
- 35
- }
- 36 //取得对应的Radio对象
- 37
- var tmpRadio = document.getElementById(tmpName);
- 38 //当前选中 其他取消选中
- 39
- if ((i - 2) == rowIndex) 40 {
- 41 tmpRadio.checked = true;
- 42
- }
- 43
- else 44 {
- 45 tmpRadio.checked = false;
- 46
- }
- 47
- }
- 48 document.all.txthid_GUID.value = rowGUID;
- 49
- }
来源: