日期:2014-05-18  浏览次数:20495 次

GridView中TemplateField触发后台事件
C# code

<asp:GridView ID="GV_List" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                            DataKeyNames="F_ID" PageSize="1" Width="99%"
                                                            AllowSorting="True" onrowdatabound="GV_List_RowDataBound" 
                                                            onrowdeleting="GV_List_RowDeleting">
                                                           
                                                            <Columns>
                                                                
                                                                <asp:TemplateField HeaderText="编辑" ItemStyle-HorizontalAlign="Center" Visible="false">
                                                                    <ItemTemplate>
                                                                        <a href="#" onclick="return Func_ListToDetail('Frm_M00Register_Edit.aspx?id=<%#Eval("F_ID")%>')">
                                                                            <img style="border: 0px" alt="" src="../../image/CRM.Mode/Grid_Edit.gif" /></a>
                                                                    </ItemTemplate>
                                                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="提交" ItemStyle-HorizontalAlign="Center" Visible="false">
                                                                    <ItemTemplate>
                                                                        <asp:ImageButton ID="IBtn_Put" runat="server" CommandName="edit" CausesValidation="False"
                                                                            ImageUrl="~/image/CRM.Mode/Grid_Put .gif" OnClientClick="return confirm('确定提交数据吗?');" />
                                                                    </ItemTemplate>
                                                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="删除" ItemStyle-HorizontalAlign="Center" ShowHeader="False"
                                                                    Visible="false">
                                                                    <ItemTemplate>
                                                                        <asp:ImageButton ID="IBtn_Delete" runat="server" CommandName="delete" CausesValidation="False"
                                                                            ImageUrl="~/image/CRM.Mode/Grid_Del.gif" OnClientClick="return confirm('确定要删除吗?');" />
                                                                    </ItemTemplate>
                                                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                                                </asp:TemplateField>