日期:2014-05-18  浏览次数:20490 次

关于DataGrid模板列的使用
LZA2003   2007-5-23   11:33   22:55   兰州   南昌   波音747   100   1000   头等舱     100   1000   公务舱     100   1000   经济舱     radiobutton  
LZA2007   2007-5-23   14:55   18:22   兰州   南昌   空客300   50   2000   头等舱     125   1500   公务舱     200   1000   经济舱         radiobutton
假如我从数据库中检索出两条这样的记录,   我想通过radiobutton只能选择其中一条怎么办,比如说:我选了LZA2003,则其radiobutton的checked值为true,另外一条则为false
谢谢了
 


------解决方案--------------------
<script language= "javascript ">
function CancelSelect(obj,tempSpan)
{
elem=obj.form.elements;
var strTemp = tempSpan;
for(i=0;i <elem.length;i++)
{
if (elem[i].type== "radio " && elem[i].id != obj.id && obj.name.substr(0,elem[i].name.indexOf( ': ')) == strTemp)
{
elem[i].checked = false;
}
}
}
</script>
------解决方案--------------------
foreach(DataGridItem DGlitem in DataGrid1.Items) //遍历DataGrid
{
BoxChecked = ((CheckBox)DGlitem.FindControl( "chkExport ")).Checked; //逐一判断是否选中
string s=DataGrid1.DataKeys[DGlitem.ItemIndex].ToString();
// string idStr = ((Label)DGlitem.FindControl( "Label1 ")).Text;//获取选中项的ID
if(BoxChecked)
{
LogicBusiness.languagetablelb mlanguagetablelb = new languagetablelb();
DataTable dt =mlanguagetablelb.xxliuyanid(s);
// string ss=Session[ "Lusername "].ToString();
EntityClass.addressbookEntity maddressbookEntity = new metalsweb.EntityClass.addressbookEntity();
LogicBusiness.addressbookQuery maddressbookQuery = new addressbookQuery();
string ss= "user4 ";
maddressbookEntity.myusername=ss;
maddressbookEntity.username=dt.Rows[0][ "Myusername "].ToString();
maddressbookEntity.Exhaletime=DateTime.Now;
maddressbookQuery.add(maddressbookEntity);
// isopenstr= "DELETE FROM GuestHouseTable WHERE (id = ' "+idStr+ " ') ";
// Sdu.ExecuteNonQueryMyData(isopenstr); //调类执行命令
}
alert( "加入到地址栏完成! ");
}