日期:2014-05-17 浏览次数:20468 次
DataTable dt = new DataTable("image"); DataColumn dc1, dc2; dc1 = new DataColumn("row", System.Type.GetType("System.Int32")); dc1.AutoIncrement = true; dc1.AutoIncrementSeed = 1; dc1.AutoIncrementStep = 1; dt.Columns.Add(dc1); dc2 = new DataColumn("catalog_id", System.Type.GetType("System.Int32")); dt.Columns.Add(dc2); DataRow dr1 = dt.NewRow(); dr1["catalog_id"] = 41; dt.Rows.Add(dr1); DataRow dr2 = dt.NewRow(); dr2["catalog_id"] = 21; dt.Rows.Add(dr2); DataRow dr3 = dt.NewRow(); dr3["catalog_id"] = 55; dt.Rows.Add(dr3); DataRow dr4 = dt.NewRow(); dr4["catalog_id"] = 33; dt.Rows.Add(dr4); GridView1.DataSource = dt; GridView1.DataBind(); string id = ""; for (int i = 0, max = dt.Rows.Count; i < max; i++) { id += dt.Rows[i]["catalog_id"].ToString() + ","; } id = id.Substring(0, id.Length - 1); Response.Write(id);
------解决方案--------------------
string PurviewIdstr = ",";
for (int j = 0; j < cb_purview.Items.Count; j++)
{
if (cb_purview.SelectedValue == "")
{
HongShangProject.Common.MessageBox.Show(this, "未选择任何权限,请选择!");
}
else
{
if (cb_purview.Items[j].Selected)
{
int _pid = 0;
int.TryParse(cb_purview.Items[j].Value.Trim(), out _pid);
PurviewIdstr += _cid + "-" + _pid + ",";
}
}
}
------解决方案--------------------
缺少
using System.Data;