本文介绍了从Gridview的可见错误BoundField中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GridView中有 BoundField

 < asp:BoundField DataField =ReportIdHeaderText =RIdVisible =false/> 

但是,当我尝试在该字段中获取文本时,它将返回空白。

  protected void gvwReports_RowCommand(object sender,GridViewCommandEventArgs e)
{
if(e.CommandName ==ViewSchedule)
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvwReports.Rows [index];
string s = row.Cells [0] .Text;






$ b

但是,如果我将
> code> BoundField的
.Visible 属性为 true

解决方案

使用客户端html隐藏

 < style type =text / css> 
.hidden
{
display:none;
}
< / style>

< asp:BoundField DataField =ReportIdHeaderText =RId>
< ItemStyle CssClass =hidden/>
< / asp:BoundField>


I have this BoundField in a GridView

<asp:BoundField DataField="ReportId" HeaderText="RId" Visible="false" />

But when I try to get text in that field, it returns empty.

protected void gvwReports_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "ViewSchedule")
    {
        int index = Convert.ToInt32(e.CommandArgument);
        GridViewRow row = gvwReports.Rows[index];
        string s = row.Cells[0].Text;
    }
}

but, it returns a correct value if I change BoundField's .Visible property to true

解决方案

try somethink like this using client side html to hide

<style type="text/css">
     .hidden
     {
         display:none;
     }
</style>

<asp:BoundField DataField="ReportId" HeaderText="RId"  >
    <ItemStyle CssClass="hidden"/>
</asp:BoundField>

这篇关于从Gridview的可见错误BoundField中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 09:39