vs.net中datagrid有一个ItemDataBound事件 ,VS2005中datagrid的ItemDataBound事件应该怎么来用?
比如:。net中的代码如下,
protected void DataGrid1_DataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType = ListItemType.Item || e.Item.ItemType = ListItemType.AlternatingItem)
{ e.Item.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=c");}
}
VS05中应该怎么实现?
比如:。net中的代码如下,
protected void DataGrid1_DataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType = ListItemType.Item || e.Item.ItemType = ListItemType.AlternatingItem)
{ e.Item.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=c");}
}
VS05中应该怎么实现?
解决方案 »
- vs2005 类中如何使用Page.FindControl
- 操作打印机任务,200分求代码(第二贴)!
- location.href 引导到页面后,IsPostBack为真?
- DevExpress 第三方控件如何使用???
- 求助!谢谢!.resources文件已损坏。试图读取ResourceReader头时出现了意外的EndofStreamException。
- 调用控制台的问题。
- 如何把一个字符串插入到richTextBox文本中光标闪烁的位置处
- 显示方法注释的问题
- Windows Form的DataGrid,如何实现按下回车就到下一个单元格,就像Tab一样。
- 高手请进入,帮俺解释一下!
- C#如何实现SHA512哈希?
- Infragistics.Win.UltraWinGrid.UltraGrid 是什么东东,给解释一下吧
DataView CartView;
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 10; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i+1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// Need to load this data only once.
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
}
void Item_Bound(Object sender, DataGridItemEventArgs e)
{
Label1.Text = Label1.Text + " " + e.Item.ItemIndex;
}
参考一下
protected void DataGrid1_DataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=c");
}
}
protected void DataGrid1_DataBound(...)
{
if(e.Item.ItemIndex>-1)
{
e.Item.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=c")
}
}
一直以为05中的gridview就是代替03中的DataGrid.