我把原码贴上, 我传了一组session到这个页用的是session[j+"reset"]表示的j是数字变量,session["reset"]是session的个数 ,我加断点发现到反斜杠中的那句话就跳到catch{}了,谢谢了. try { //获得零部件的ID string strcomputerID = (string)Session["computer_id"]; //连接数据库 DB db = new DB(this.Page.Application); string strSelect; strSelect = "select type.type_name,part.component_id,part.list_id,part.buy_price,part.note,type.only_flag from brogame_components part left join brogame_components_type type on part.type_id=type.type_id where 1=1 and part.user_flag=0 and part.delete_flag=0"; strSelect = strSelect + " order by type.type_name"; DataTable dTable = db.Select(strSelect, "brogame_components"); for (int i = 0; i < dTable.Rows.Count; i++) { for (int j = 0; j < Convert.ToUInt16(Session["reset"]); j++) { if (dTable.Rows[i]["component_id"].ToString() == Convert.ToString(Session[Convert.ToString(j) + "reset"])) {
{
foreach (GridViewRow myrow in GridView1.Rows)
{
if (myrow.Cells[0].Text == id)
{
CheckBox cb = (CheckBox)myrow.FindControl("CheckBoxid");
cb.Checked = true;
} } }
try
{
//获得零部件的ID
string strcomputerID = (string)Session["computer_id"];
//连接数据库
DB db = new DB(this.Page.Application);
string strSelect;
strSelect = "select type.type_name,part.component_id,part.list_id,part.buy_price,part.note,type.only_flag from brogame_components part left join brogame_components_type type on part.type_id=type.type_id where 1=1 and part.user_flag=0 and part.delete_flag=0";
strSelect = strSelect + " order by type.type_name";
DataTable dTable = db.Select(strSelect, "brogame_components");
for (int i = 0; i < dTable.Rows.Count; i++)
{
for (int j = 0; j < Convert.ToUInt16(Session["reset"]); j++)
{ if (dTable.Rows[i]["component_id"].ToString() == Convert.ToString(Session[Convert.ToString(j) + "reset"]))
{
/////////////////CheckBox cb = Select_GridView.Rows[i].FindControl("SelectBox") as CheckBox;////////////////////////////
cb.Checked = true;
}
} }
if (dTable.Rows.Count >= 0)
{
message.Text = "";
this.Select_GridView.DataSource = dTable;
this.Select_GridView.DataBind();
} db.CloseConnect();
}
catch (Exception)
{ }