GridView中如何取得隐藏列的值?

直接对 <asp:BoundField  隐藏列取值不行,改用模板列实现

<asp:TemplateField Visible="false">
                    
<ItemTemplate>
                        
<asp:label ID="lblTask" runat="server" Text='<%# Eval("task_status") %>' />
                    
</ItemTemplate>
            
</asp:TemplateField>

然后,

protected void SmartGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    
{
        
if (e.Row.RowType == DataControlRowType.DataRow)
        
{
            
switch (((Label)e.Row.FindControl("lblTask")).Text)
            
{
                
case "0":
                    e.Row.CssClass 
= "color_task_init";
                    
break;
                
case "1":
                    e.Row.CssClass 
= "color_task_back";
                    
break;
                
case "2":
                    e.Row.CssClass 
= "color_task_wait";
                    
break;
                
case "3":
                    e.Row.CssClass 
= "color_task_confirm";
                    
break;
                
case "4":
                    e.Row.CssClass 
= "color_task_finish";
                    
break;
                
case "10":
                    e.Row.CssClass 
= "color_task_cancel";
                    
break;
                
case "&nbsp;":
                    e.Row.CssClass 
= "color_terminal";
                    
break;
                
default:
                    e.Row.CssClass 
= "color_terminal";
                    
break;
            }

        }

    }

posted @ 2007-08-29 12:59  Ready!  阅读(499)  评论(0编辑  收藏  举报