数据列表中的itemcommand问题 [英] itemcommand issue in datalist
本文介绍了数据列表中的itemcommand问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写此代码来设置数据列表项目的背景色
i write this code for setting backcolor of datalist items
protected void dlTrades_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
System.Data.DataRowView drv = (System.Data.DataRowView)(e.Item.DataItem);
string hld = (string)drv.Row["Color"].ToString();
if (hld == "RED")
{
e.Item.BackColor = System.Drawing.Color.Red;
}
但是在dlTrades_itemCommand事件上,项目的背景颜色消失了...我如何在itemcommand事件上保留这些颜色?
答复ASAP
But on dlTrades_itemCommand event backcolor of items goes away... how can i keep these color on itemcommand event???
Reply ASAP
推荐答案
将断点放在itemdatabound事件上,然后在dlTrades_itemCommand事件完成后尝试触发itemcommand事件检查,您的代码是否再次进入dlTrades_ItemDataBound. .
如果没有到达那里,那么要获得背景色,您必须在dlTrades_itemCommand事件完成后重新整理列表
试试看,我认为在调试代码后,您会发现您的代码在哪里很弱,无法重新绑定背景色..
put the breake point on itemdatabound event and then try to fire itemcommand event check after completion of your dlTrades_itemCommand event your code again goes to dlTrades_ItemDataBound this or not..
if it is not going to there then for getting a back color you have to refreace your list after your dlTrades_itemCommand event is complete
try this it will i think after you debug your code you will find that where is your code is weak to rebind the back color..
请参阅此链接,
http://msdn.microsoft.com/en-us/library/6y92e1ze.aspx [ ^ ]
您需要在itemCommand之后绑定您的数据列表.
Refer this link,
http://msdn.microsoft.com/en-us/library/6y92e1ze.aspx[^]
U need to bind your datalist after itemCommand.
试试这个-
Hi,
Try this-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
这篇关于数据列表中的itemcommand问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文