根据数据库数据在gridview中显示图像 [英] display imge in gridview based on databse data

查看:85
本文介绍了根据数据库数据在gridview中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在使用gridview显示数据,在这里我从数据库中检索了几行信息,在这里我有数量列.如果总数为0,我必须添加所有检索到的行数列,我必须在gridview中将状态显示为close.如何实现上述功能
请帮助我

解决方案

嗨 斯里尼瓦斯,

请执行以下操作:
我已将 DataKeyNames = Total 添加到gridview

 <   asp:GridView     DataKeyNames   ="     ID   ="  gvName"  runat   服务器" 
                   span>    onrowdatabound   ="  gvName_RowDataBound1" <  /asp:GridView  >  



 受保护的  void  gvName_RowDataBound(对象发​​件人,GridViewRowEventArgs e)
   {
       如果(例如,Row.RowType == DataControlRowType.DataRow)
       {
            int  total = Convert.ToInt32(gvName.DataKeys [ 0 ].Value);
           如果(总计==  0 )
           {
               // 我认为您的第四列是帐户状态" 
               e.Row.Cells [ 3 ].Text = " ;
           }
       }
   } 



谢谢,
Imdadhusen


hi i am using gridview for displaying data , here i retrieve few rows of information from database, In this i have amount column . i have to add all the retrieved rows amount column if the total amount will be 0 , i have to show status as close in gridview. how to do above functionality
help me please

解决方案

Hi Srinivas,

Please do the following:
I have added DataKeyNames=Total to the gridview

<asp:GridView DataKeyNames="Total" ID="gvName" runat="server"

        onrowdatabound="gvName_RowDataBound1">
    </asp:GridView>



protected void gvName_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           int total = Convert.ToInt32(gvName.DataKeys[0].Value);
           if (total == 0)
           {
               //I assumed your 4th number of column is for Account Status
               e.Row.Cells[3].Text = "Closed";
           }
       }
   }



Thanks,
Imdadhusen


这篇关于根据数据库数据在gridview中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆