This is a migrated thread and some comments may be shown as answers.

[Solved] GridTemplateColumn does not show image during rebind

4 Answers 194 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erwin
Top achievements
Rank 1
Erwin asked on 02 Jun 2009, 10:57 AM
I copied a sample code from your demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/webmail/defaultvb.aspx

<
telerik:GridTemplateColumn UniqueName="TemplateColumn3" Groupable="False">
   <HeaderStyle Width="20px"></HeaderStyle>
   <ItemStyle Height="35px"></ItemStyle>
   <ItemTemplate>
<asp:ImageButton ID="MailFlagImageButton" BorderWidth="0px" CommandName="ChangeFlag"
ImageUrl='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Flagged"))? "img/MailFlagRed.gif" : "img/MailFlag.gif" %>'

    AlternateText="Change Flag" Style="float: right; cursor: pointer;" runat="server">
    </asp:ImageButton>
    </ItemTemplate>
</telerik:GridTemplateColumn>

I this demo it shows that an image is being used to flag the item....
--------
In the beginning of the page I have a grid that have nothing in it. The user will select items above the grid then when i press purchase, the item selected will be displayed in the grid...

My problem is that when I display the items in the grid no image will display.. (note: the header of the ItemTemplate shows, but does not have any picture below it.)

the grid was rebinded.
The main problem is that the image does not display......
I tried using telerik:GridButtonColumn and made its type into image but the problem is still their no image is displayed
How can i solve this problem......

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 04 Jun 2009, 01:51 PM
Hi Erwin,

Can you please supply some additional information on your setup? How is the grid control populated with data, and rebound?

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erwin
Top achievements
Rank 1
answered on 05 Jun 2009, 08:10 AM
first i bind it using a blank object then after a user select an item outside the grid(in a treeview with checkbox)

the grid will papulate using:

grd.set_dataSource(obj);
grd.dataBind();

after this the image in telerik:GridButtonColumn does not show the only thing that i can see is its header text
i also tried this with the telerik:GridTemplateColumn same thing happend!!!
0
Erwin
Top achievements
Rank 1
answered on 08 Jun 2009, 09:58 AM
I found another thing....

I initialize my grid to have 2 rows and use GridTemplateColumn that contains a checkbox....

page load i did this:

 RadGrid1.DataSource = new Object[]{'a','b'};

the first row had 'a' values and the second have 'b'

in my GridTemplateColumn the checkbox show

after page load of the page I bind the grid using its
<DataBinding SelectMethod="GetData" SelectCountMethod="GetCount" Location="Default.aspx" SortParameterType="Linq" FilterParameterType="Linq">   </DataBinding> 

    public static List<object> GetData(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
    {
        List<object> data = new List<object>();
        for (int i = 1; i < 26; i++)
        {
            data.Add(new
            {
                ID = i,
                ID1 = i,
                ID2 = i,
                ID3 = i,
                ID4 = i,
                ID5 = i,
                ID6 = i,
                ID7 = i,
                ID8 = i,
                ID9 = i,
                ID10 = i,
                ID11 = i,
                ID12 = i
            });
        }

        return data.Skip(startRowIndex).Take(maximumRows).ToList();
    }

    [WebMethod]
    public static int GetCount()
    {
        return 25;
    }

this is an example from 131342_radgridclientbindingstaticheaders.zip i downloaded in this site plus some minor changes like putting a

GridTemplateColumn and putting a value in the page load..


Why is the GridTemplateColumn itemtemplate not showing..... but its header showed

0
Sebastian
Telerik team
answered on 10 Jun 2009, 11:36 AM
Hello Erwin,

Can you please verify that you are using the latest version 2009.1.527 of RadControls for ASP.NET AJAX in your project? Thus the built-in GridButtonColumn/GridCheckBoxColumn controls should be rendered as expected when you increase the page size of the grid. Upgrade instructions can be found here.

Furthermore, note that since RadGrid transfers JSON data when bound on the client, if you have some kind of templates - GridTemplateColumn/ NestedViewTemplate - there is no proper way for populating the controls in these templates as they are templates. However, for the rows that are initially created on the server (these PageSize items), RadGrid will manage to populate a control in GridTemplateColumn  if the control in that ItemTemplate has ID set equal to the DataField property of that column.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Erwin
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Erwin
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or