Hello,
i use VS 2010 SP1 and NetAdvantage 11.1.20111.2064. I use a Webdatagrid with a SqlDatasource and a templated field.
<ig:TemplateDataField Key="tf_Warenkorb" VisibleIndex="1" Width="30px"> <ItemTemplate> <asp:Image ID="i_WK" runat="server" ImageUrl="~/Pictures/Warenkorb4.png" ImageAlign="Middle" ToolTip="In den Warenkorb legen." CssClass="grid" /> </ItemTemplate> <Header Text="Warenkorb"></Header>
</ig:TemplateDataField>
i catch the client-side Cell-Click-Event
<Behaviors> <ig:Selection RowSelectType="Single"> <SelectionClientEvents CellSelectionChanged="wdg_Liste_Selection_CellSelectionChanged" /> </SelectionClientEvents>
</ig:Selection> <ig:RowSelectors RowNumbering="True"> </ig:RowSelectors> <ig:Sorting> <ColumnSettings> <ig:SortingColumnSetting ColumnKey="tf_Warenkorb" Sortable="False" /> </ColumnSettings> </ig:Sorting> <ig:Paging PageSize="30"> </ig:Paging></Behaviors>
In the function, i check the Cell with the Click-Event and do some stuff. If cell 1 is clicked, the item goes in the basket (in my javascript). Now i need to change this, depending on the value of an other cell in the row (no problem). But i also need to change the image of the tempated field. So i try to use the 'InitializeRow' Event in code behind.
protected void wdg_Liste_Init_Row(object sender, RowEventArgs e) { if (e.Row.Items[12].Value.Equals("1")) { e.Row.Items[1].Value = ?????; } }
But how can i change the image of the Templated field ( my Row.Item[1] ) ??
Hello page,
I am looking into this matter of changing a template field in the code behind. I am doing some research into how to achieve this and I will give you a progress update by Tuesday.
Sincerely,Mike P.Developer Support EngineerInfragistics, Inc.www.infragistics.com
You can achieve this by finding the control off of the item in the row in the InitializeRow. Once you find the control you can change the ImageUrl. For Example:
if (e.Row.Index == 3){ Image img = (Image)e.Row.Items[0].FindControl("Image1"); img.ImageUrl = "~/ig_res/Default/images/ig_tblTriEdit.gif"; }
I have also attached a sample that demonstrates this behavior. I use Nwind database for data.
Please let me know if you have any questions concerning this matter.
Hello Mike,
your sample is ok and give me a hint in the right direction. In my own words: catch the row and the field and then get the control with the 'FindControl'-method without the problems of the possible container around this control.
Thanks for your reply and i must say that the whole support from Infragistics here in the forum is getting better in the last time.
Patric