protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
string fcode = this.GridView1.DataKeys[index].Value.ToString();
if (e.CommandName != "AddtoBus")
{
if (Session["bus"] == null)
{
System.Collections.Hashtable ht = new Hashtable();
ht.Add(fcode, 1);
Session["bus"] = ht;
}
else
{
System.Collections.Hashtable ht = (Hashtable)Session["bus"];
if (ht[fcode] == null)
{
ht[fcode] = 1;
}
else
{
ht[fcode] = (int)ht[fcode] + 1;
}
Session["bus"] = ht;
}
}
}这是添加段的代码?哪位高手点一下....
{
int index = Convert.ToInt32(e.CommandArgument);
string fcode = this.GridView1.DataKeys[index].Value.ToString();
if (e.CommandName != "AddtoBus")
{
if (Session["bus"] == null)
{
System.Collections.Hashtable ht = new Hashtable();
ht.Add(fcode, 1);
Session["bus"] = ht;
}
else
{
System.Collections.Hashtable ht = (Hashtable)Session["bus"];
if (ht[fcode] == null)
{
ht[fcode] = 1;
}
else
{
ht[fcode] = (int)ht[fcode] + 1;
}
Session["bus"] = ht;
}
}
}这是添加段的代码?哪位高手点一下....
报错的提示...
{
TextBox tb=(TextBox)dl.FindControl("TextBox1");//找到文本框
int newfcode=Convert.ToInt32(tb.Text.ToString());//查出文本框里面的值
Hashtable ht=(Hashtable)Session["bus"];//把session["bus"]对象赋值给哈希表 ht
string fcode = this.DataList1.DataKeys[DataList1.SelectedIndex].ToString();
int oldpid=(int)ht[fcode];//求得原来的数量
if (newfcode != oldpid)//如果文本框里的值不等于原来的数量,就用新的更换到哈希表中的值
{
ht[fcode] = newfcode;
}
Session["bus"]=ht;//最后再更新Session 对象 */
} 这样改可以么?!
{
TextBox tb=(TextBox)dl.FindControl("TextBox1");/ 到文本框
int newfcode=Convert.ToInt32(tb.Text.ToString());//查出文本框里面的值
Hashtable ht=(Hashtable)Session["bus"];//把session["bus"]对象赋值给哈希表 ht
string fcode = DataList1.Items[0].ItemIndex.ToString();
int oldpid=(int)ht[fcode];//求得原来的数量
if (newfcode != oldpid)//如果文本框里的值不等于原来的数量,就用新的更换到哈希表中的值
{
ht[fcode] = newfcode;
}
Session["bus"]=ht;//最后再更新Session 对象 */
} 我重新改了改还是不行阿?!