我想选择datalist的索引id我的代码是
protected void dlst1_SelectedIndexChanged1(object sender, EventArgs e)
{
indexId = Convert.ToInt32(dlst1.DataKeys[dlst1.SelectedIndex]);
}
我根据所选的项目索引从左向右移动项目,但我得到的是indexId 0它得到的是swap反向,它应该从左向右移动但它从右向左移动
protected void btnMoveright_Click(object sender, ImageClickEventArgs e)
{
List<ArrayList> temp = 1path;
ArrayList temp2 = temp[indexId];
temp[indexId] = temp[indexId + 1];
temp[indexId + 1] = temp2;
for (int i = 0; i < temp.Count; i++)
{
ArrayList lst = temp[i];
tb.Rows.Add(Convert.ToInt32(lst[0]), lst[1].ToString(), lst[2].ToString(), i);
}
dlst1.DataSource = tb;
DataBind();
path = BaseDAL.GetImg(Ids);
for (int i = 0; i < path.Count; i++)
{
ArrayList lst = path[i];
tb.Rows.Add(Convert.ToInt32(lst[0]), lst[1].ToString(), lst[2].ToString(), i);
}
dlst2.DataSource = tb;
DataBind();
}
请有人帮助我在这个,如何移动项目
我只添加了
int c = 0;
foreach (ArrayList x in temp)
{
if (indexId == Convert.ToInt32(x[0]))
{
break;
}
c++;
}
if ((temp.Count - 1) > c)
{
// my old code
// only replaced indexId to c. Now i am able to move the item
}