Webgrid celltemplate value not showing up when we refresh the grid or sort the column.

1 reply. Last post: January 10, 2013 4:33 AM by Bernard Xiang
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
psr Member

Hi,

I am using Webgrid7, .NET3.5 in my project. In that for two columns I am using cellTemplate.

When the page loads first time it it working fine but when I click on grid refresh or click on column header to sort, the cell template values are not showing.

these are my grid cell templte columns

<ISWebGrid:WebGridColumn Name="Type" ColumnType="Template">
                    <CellTemplate>
                        <asp:Label ID="labelType" runat="server" Text='<%# GetReportType(Eval("isTableReport")) %>'></asp:Label>
                    </CellTemplate>
                </ISWebGrid:WebGridColumn>
                <ISWebGrid:WebGridColumn  Name="ImportTags" ColumnType="Template">
                    <CellTemplate>
                        <asp:ImageButton ID="buttonImport" runat="server" ImageUrl="../Content/CSS/Themes/Default/images/Import-16px-b.png" 
                        Visible='<%# ShowImport(Eval("isTableReport")) %>'
                            ToolTip="Click to import" OnClientClick="Editing('Import');return false;"/>
                    </CellTemplate>
                </ISWebGrid:WebGridColumn>

The following methods are created in server side and called in cell templates

protected string GetReportType(object isTableReport)
        {
            string str = string.Empty;
            if ((bool)isTableReport)
            {
                str = "No";
            }
            else
            {
                str = "Yes";
            }
            return str;
        }
        protected bool ShowImport(object isTableReport)
        {
            bool enable = false;
            if ((bool)isTableReport)
            {
                enable = false;
            }
            else
            {
                enable = true;
            }
            return enable;
        }

this grid datasource is object List.

 

Please provide some sample code which works fine if I use two celltemplate columns for same value.(in the above example it is "isTableReport")

 

Thanks.

All times are GMT -5. The time now is 8:07 PM.
Previous Next