Asp.net站内短消息 添加电话本明细 求教!
添加地址本的同时 也要添加一个地址本明细 点添加后地址本添加成功 可是明细添加不进去 不知道为什么?protected void Button1_Click(object sender, EventArgs e)
{
DataTable table = (DataTable)(Session["userTable"]);
int OwnerUserId=Int32.Parse(table.Rows[0][0].ToString());
string AddressBookName=AddressBookName1.Text.Trim();
string Remark = AddressRemark1.Text.Trim();
int Addaddressbook = abs.InsertAddressBook(OwnerUserId,AddressBookName,Remark);
try
{
int AddressBookId = abd.SelectAddressBookId(AddressBookName);
//Response.Write("<script>alert('" + AddressBookId + "')</script>");
for (int i = 0; i < AddressBookDataGrid.Items.Count; i++)
{
if (((CheckBox)AddressBookDataGrid.Items[i].FindControl("CheckBox1")).Checked == true)
{
int ContactorId = Int32.Parse(((Label)(AddressBookDataGrid.Items[i].FindControl("Label"))).Text.Trim());*******单步运行到这里 ContactorId =0了 然后直接进catch了报异常 ContactorId 接收方法不对吗?System.FormatException: 输入字符串的格式不正确
abd.InsertAddressBookDetail(AddressBookId, ContactorId);
}
}
}
catch (Exception eee)
{
Response.Write(eee);
}
}
这是添加类的方法
public int InsertAddressBookDetail(int AddressBookId, int ContactorId)
{
string sql = "insert into AddressBookDetail values(" + AddressBookId + "," + ContactorId + ")";
return dbo.Excute(sql);
}
[[it] 本帖最后由 chairmancui 于 2008-3-30 15:15 编辑 [/it]]