<script type="text/javascript">
function selValue() {
var val = '';
var gridView = document.getElementById('<%=dgvData.ClientID %>');
for (i = 1; i <= gridView.rows.length; i++) {
var inputs = gridView.rows[i].getElementsByTagName('input');
if (inputs != null) {
if (inputs[0].type == "checkbox") {
if (inputs[0].checked) {
val = val + eval(gridView.rows[i].cells[2].value) + ','
}
}
}
}
window.opener.document.getElementById("txtText").value = val;
window.close();
}
</script>
<script type="text/javascript">
function selValue(val,focus) {
var gridview = document.getElementById('dgvData');
var len = gridview.rows.length;
for (i = 1; i < len; i++) {
var input = gridview.rows[i].cells[0].getElementsByTagName('input');
if(input[0].type == 'checkbox')
if (input[0].checked == true) {
val = val + gridview.rows[i].cells[1].innerHTML + ','; //OK
}
}
if (val != '') {
//alert(val);
window.opener.document.getElementById(focus).value = val;
window.close();
} else {
alert("ไม่มีรายการที่ถูกเลือก");
}
}
</script>
//////---------------------------------------------------------------------------------------------------
แต่ในกรณีที่ไม่ได้เป็น pop UP เราก็อาจจะใช้แบบนี้ก็ได้นะครับ
void selValue()
{
CheckBox chkID;
int i;
lblText.Text = "";
mychkStr = "";
for (i = 0; i <= dgvData.Rows.Count - 1; i++)
{
chkID = (CheckBox)dgvData.Rows[i].FindControl("chkBxSelect");
if (chkID.Checked)
{
mychkStr += "," + dgvData.Rows[i].Cells[1].Text;
}
}
if (mychkStr != "")
{
Session["select"] = mychkStr.Substring(1);
}
else {
ShowPopUpMsg("ไม่มีข้อมูลที่ถูกเลือก");
}