Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
How to generate ItemTemplate in webdatagrid use code.
posted

  <ItemTemplate>
                                                        <img id="Img1" runat="server" onclick="BtPopShow2(this,'MeasurementPop','ContainerData',1)" src="~/Images/icon_2.gif"
                                                            title="计算交接计量" />
                                                        <img id="Img2" runat="server" onclick="BtPopShow2(this,'InventoryMeasurementPop','ContainerData',2)" src="~/Images/icon_3.gif"
                                                            title="计算盘点计量" />
                                                        <img id="Img3" runat="server" onclick="BtPopShow2(this,'BackMeasurementPop','ContainerData',3)" src="~/Images/icon_4.gif"
                                                            title="计算后尺计量" />
                                                        <img id="Img4" runat="server" onclick="BtPopShow3(this,'DecimeterPop')" src="../Images/icon_5.gif" title="查询分米容积表" />
                                                        <img id="Img5"  src="../Images/icon_6.gif" title="查询历史计量结果" />
                       </ItemTemplate>

 

 

How can I write C# code to fill the ItemTemplate in webdatagrid?

Parents
No Data
Reply
  • 33839
    Suggested Answer
    posted

    Hi XiaQin,

    I'm not sure whether you're talking about adding the TemplateDataField in the code-behind or not.  If you have view state on, you only need to add it once.  But you will need to apply the ItemTemplate (or alt, footer, and header templates) on each postback.  You simply type case the column to a TemplateDataField and set the ItemTemplate property to an instance of a class that implements ITemplate.  Then you implement InstantiateIn method.  Here you would make instances of Image objects and add them to the container.Controls collection.

    regards,

    David Young

Children
No Data