数据插入的问题 判断一下是否为null,为null给个初始值试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 a.aspx页面<script> function SetInterestAndLove(chk) { var arr = ''; var arrHead = ","; arr = document.getElementById("<%=ClientID%>:txtInterestAndLove").value+","; if(arr != ",") { arrHead += arr; } else { arr = ""; } var str = chk.value+","; if(chk.checked) { if(arrHead.indexOf(","+str)<0) { arr += str; } } else { if(arrHead.indexOf(","+str)>=0) { arr = arr.replace(str,""); } } if(arr.lastIndexOf(",")>=0) { arr = arr.substring(0,arr.length-1); } document.getElementById("<%=ClientID%>:txtInterestAndLove").value = arr; } </script><input name="checkboxInterestAndLove" id="checkboxInterestAndLove1" runat="server" onclick="SetInterestAndLove(this)" type="checkbox" class="hei12" value="艺术"> 艺术 <input type="checkbox" onclick="SetInterestAndLove(this)" id="checkboxInterestAndLove2" runat="server" name="checkboxInterestAndLove" class="hei12" value="团体运动"> 团体运动<input type="checkbox" id="checkboxInterestAndLove3" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="健身/跑步"> 健身/跑步 <input type="checkbox" id="checkboxInterestAndLove4" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="钓鱼"> 钓鱼 <input type="checkbox" id="checkboxInterestAndLove5" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="骑单车/摩托车"> 骑单车/摩托车<br><input type="checkbox" id="checkboxInterestAndLove6" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="网球"> 网球 <input type="checkbox" id="checkboxInterestAndLove7" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="高尔夫球"> 高尔夫球 <input type="checkbox" id="checkboxInterestAndLove8" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="滑冰/滑雪"> 滑冰/滑雪 <input type="checkbox" id="checkboxInterestAndLove9" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="棋类"> 棋类 <input type="checkbox" id="checkboxInterestAndLove10" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="计算机/网络"> 计算机/网络<br><input type="checkbox" id="checkboxInterestAndLove11" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="游泳"> 游泳 <input type="checkbox" id="checkboxInterestAndLove12" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="电脑游戏"> 电脑游戏 <input type="checkbox" id="checkboxInterestAndLove13" runat="server" onclick="SetInterestAndLove(this)" name="checkboxInterestAndLove" class="hei12" value="乒乓球"> 乒乓球 <input type="hidden" id="txtInterestAndLove" name="txtInterestAndLove" runat="server">a.aspx.csprotected System.Web.UI.HtmlControls.HtmlInputHidden txtInterestAndLove; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove1; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove2; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove3; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove4; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove5; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove6; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove7; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove8; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove9; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove10; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove11; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove12; protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove13; /// <summary> /// 兴趣与爱好 /// </summary> public string InterestAndLove { get { return txtInterestAndLove.Value; } set { txtInterestAndLove.Value = value; } } private void Page_Load(object sender, System.EventArgs e) { if (InterestAndLove != "") { SetCheckBox(checkboxInterestAndLove1); SetCheckBox(checkboxInterestAndLove2); SetCheckBox(checkboxInterestAndLove3); SetCheckBox(checkboxInterestAndLove4); SetCheckBox(checkboxInterestAndLove5); SetCheckBox(checkboxInterestAndLove6); SetCheckBox(checkboxInterestAndLove7); SetCheckBox(checkboxInterestAndLove8); SetCheckBox(checkboxInterestAndLove9); SetCheckBox(checkboxInterestAndLove10); SetCheckBox(checkboxInterestAndLove11); SetCheckBox(checkboxInterestAndLove12); SetCheckBox(checkboxInterestAndLove13); } } private void SetCheckBox(System.Web.UI.HtmlControls.HtmlInputCheckBox CheckBox) { string strNewCarPriceValue = ","+InterestAndLove+","; if (strNewCarPriceValue.IndexOf(","+CheckBox.Value+",")>=0) { CheckBox.Checked = true;; } else { CheckBox.Checked = false; } } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器 /// 修改此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion 我考 你那个 信息保持周期 还是可以多选的啊 如果是单选就好办了, 用个switch就搞定了 这是写的一个ascx你可以把他改成你所要的 [请教]GridView中如何修改指定行asp:TemplateField中的内容 水晶报表工具栏会长出来一块,求解决 请问想要做一个类似任务栏屏幕右下角里面的时钟,该找哪些关键词阿? 上帝才能解决的问题 用微软的WWF做工作流平台,刚学散分 高手请进~~ 从哪能找到ase ado.net (sybase)的下载? 如何取得局域网内计算机运行程序的列表? C# 截取字符与过滤问题 如何为控件添加非默认的事件? 如何储存为自定义的文件类型 serialPort控件 为什么发送的时候没有数据呢?
<script>
function SetInterestAndLove(chk)
{
var arr = '';
var arrHead = ",";
arr = document.getElementById("<%=ClientID%>:txtInterestAndLove").value+",";
if(arr != ",")
{
arrHead += arr;
}
else
{
arr = "";
}
var str = chk.value+",";
if(chk.checked)
{
if(arrHead.indexOf(","+str)<0)
{
arr += str;
}
}
else
{
if(arrHead.indexOf(","+str)>=0)
{
arr = arr.replace(str,"");
}
}
if(arr.lastIndexOf(",")>=0)
{
arr = arr.substring(0,arr.length-1);
}
document.getElementById("<%=ClientID%>:txtInterestAndLove").value = arr;
}
</script>
<input name="checkboxInterestAndLove" id="checkboxInterestAndLove1" runat="server" onclick="SetInterestAndLove(this)"
type="checkbox" class="hei12" value="艺术"> 艺术 <input type="checkbox" onclick="SetInterestAndLove(this)" id="checkboxInterestAndLove2"
runat="server" name="checkboxInterestAndLove" class="hei12" value="团体运动"> 团体运动
<input type="checkbox" id="checkboxInterestAndLove3" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="健身/跑步"> 健身/跑步 <input type="checkbox" id="checkboxInterestAndLove4" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="钓鱼"> 钓鱼 <input type="checkbox" id="checkboxInterestAndLove5" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="骑单车/摩托车"> 骑单车/摩托车<br>
<input type="checkbox" id="checkboxInterestAndLove6" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="网球"> 网球 <input type="checkbox" id="checkboxInterestAndLove7" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="高尔夫球"> 高尔夫球 <input type="checkbox" id="checkboxInterestAndLove8" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="滑冰/滑雪"> 滑冰/滑雪 <input type="checkbox" id="checkboxInterestAndLove9" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="棋类"> 棋类 <input type="checkbox" id="checkboxInterestAndLove10" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="计算机/网络"> 计算机/网络<br>
<input type="checkbox" id="checkboxInterestAndLove11" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="游泳"> 游泳 <input type="checkbox" id="checkboxInterestAndLove12" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="电脑游戏"> 电脑游戏 <input type="checkbox" id="checkboxInterestAndLove13" runat="server" onclick="SetInterestAndLove(this)"
name="checkboxInterestAndLove" class="hei12" value="乒乓球"> 乒乓球 <input type="hidden" id="txtInterestAndLove" name="txtInterestAndLove" runat="server">a.aspx.cs
protected System.Web.UI.HtmlControls.HtmlInputHidden txtInterestAndLove;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove1;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove2;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove3;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove4;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove5;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove6;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove7;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove8;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove9;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove10;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove11;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove12;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox checkboxInterestAndLove13;
/// <summary>
/// 兴趣与爱好
/// </summary>
public string InterestAndLove
{
get
{
return txtInterestAndLove.Value;
}
set
{
txtInterestAndLove.Value = value;
}
} private void Page_Load(object sender, System.EventArgs e)
{
if (InterestAndLove != "")
{
SetCheckBox(checkboxInterestAndLove1);
SetCheckBox(checkboxInterestAndLove2);
SetCheckBox(checkboxInterestAndLove3);
SetCheckBox(checkboxInterestAndLove4);
SetCheckBox(checkboxInterestAndLove5);
SetCheckBox(checkboxInterestAndLove6);
SetCheckBox(checkboxInterestAndLove7);
SetCheckBox(checkboxInterestAndLove8);
SetCheckBox(checkboxInterestAndLove9);
SetCheckBox(checkboxInterestAndLove10);
SetCheckBox(checkboxInterestAndLove11);
SetCheckBox(checkboxInterestAndLove12);
SetCheckBox(checkboxInterestAndLove13);
}
} private void SetCheckBox(System.Web.UI.HtmlControls.HtmlInputCheckBox CheckBox)
{
string strNewCarPriceValue = ","+InterestAndLove+",";
if (strNewCarPriceValue.IndexOf(","+CheckBox.Value+",")>=0)
{
CheckBox.Checked = true;;
}
else
{
CheckBox.Checked = false;
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion