GridView RO颜色变化 [英] Gridview ro color change
本文介绍了GridView RO颜色变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是gridview,其中我们选择了一行,当我们选择该行时,它的颜色发生了变化,并且未选择该行的行命令上的颜色不同.
请帮助我
我的代码是:
I am using a gridview in which we select a row,when we select the row then its color changed and which row is not selected that color different on rowcommand.
pls help me
my code is:
int intRowindex = int.Parse(e.CommandArgument.ToString()) - 1;
GridViewRow selectedrow = grdRawDevice.Rows[intRowindex];
selectedrow.BackColor = System.Drawing.Color.Aqua;
pnlSite.Visible = true;
hfIndex.Value = intRowindex.ToString();
lblDeviceID = (Label)grdRawDevice.Rows[intRowindex].FindControl("lbl_deviceID");
FillData();
推荐答案
因此,您需要存储以前的rowindex,我建议您将数据保存在viewstate中,检查代码
so for this you need to store the previous rowindex , i suggest you to save data in viewstate check the code
public int selectedroindex
{
get
{
if(ViewState["selectedroindex"]!=null)
return (int)ViewState["selectedroindex"];
else
return -1;
}
set
{
ViewState["selectedroindex"]= value;
}
}
执行完此操作后,只需恢复上一行的颜色,然后再更改所选行的颜色
after you do this just restore color back for the previous row before changing selected row color
GridViewRow prevselectedrow = grdRawDevice.Rows[intRowindex];
prevselectedrow.BackColor = System.Drawing.Color.white;//set to orignal colur
int intRowindex) = int.Parse(e.CommandArgument.ToString()) - 1;
GridViewRow selectedrow = grdRawDevice.Rows[intRowindex];
selectedrow.BackColor = System.Drawing.Color.Aqua;
pnlSite.Visible = true;
hfIndex.Value = intRowindex.ToString();
lblDeviceID = (Label)grdRawDevice.Rows[intRowindex].FindControl("lbl_deviceID");
FillData();
这篇关于GridView RO颜色变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文