• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

Why doesnt gridview row command fire.

I have the following code.  I want to be able to click on the imagebutton with the id='linkbutton6' and capture the gridview_rowcommand event.  I have done this on other pages, but for some reason I get a postback, but it doesn't go to mygrid_rowcommand event.  

Can anybody tell where I am missing the boat.

thanks in advance
 <asp:UpdatePanel ID="PanelDetails" runat="server">
    <Triggers></Triggers>
    <ContentTemplate>
        <table style="width: 85%; margin-left: 5%;">
            <tr>
                <td style="text-align: center;" colspan="2">
                <asp:GridView ID="myGrid" runat="server" AutoGenerateColumns="False" BackColor="#99FFFF"
                    BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ID" ForeColor="Black"
                    GridLines="None" AllowPaging="True" PageSize="25" Width="100%"
                    HeaderStyle-HorizontalAlign="Left" AllowSorting="True" 
                        EmptyDataText="No Records Found">
                
                
                <Columns>
                    <asp:TemplateField HeaderText="ID" Visible="False">
                        <ItemTemplate>
                            <asp:Label ID="lblID" runat="server" Text='<%# Container.DataItemIndex %>' Visible="false"></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="WO No.">
                        <ItemTemplate>
                            <asp:Label ID="lblWONum" runat="server" Text='<%# Bind("wo_number") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="BldgID">
                        <ItemTemplate>
                            <asp:Label ID="lblBldgID" runat="server" Text='<%# Bind("BldgID") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Unit ID">
                        <ItemTemplate>
                            <asp:Label ID="lblUnitID" runat="server" Text='<%# Bind("UnitID") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Room">
                        <ItemTemplate>
                            <asp:Label ID="lbRoom" runat="server" Text='<%# Bind("ItemGroup") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                            <asp:Label ID="lblDescrption" runat="server" Text='<%# Bind("ItemDescription") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Qty">
                        <ItemTemplate>
                            <asp:Label ID="lblQty" runat="server" Text='<%# Bind("ItemQty") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Installed Date">
                        <ItemTemplate>
                            <asp:Label ID="lblInstalled" runat="server" Text='<%# Eval("InstalledDate", "{0:d}") %>' Width="100px"></asp:Label>
                        </ItemTemplate><%--
                                                <EditItemTemplate>
                            <asp:TextBox ID="txtInstalled" runat="server" Text='<%# Eval("InstalledDate", "{0:d}") %>'  Width="100px" AutoPostBack="true"></asp:TextBox>
                            
                                                                                 
                            <asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" Enabled="True"
                                TargetControlID="txtInstalled">
                            </asp:CalendarExtender>
                                                    <itemstyle horizontalalign="Left" />
                                                    <headerstyle horizontalalign="Left" />
                                                </EditItemTemplate>--%>
                    </asp:TemplateField>
                               
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:ImageButton ID="LinkButton6" runat="server" CommandName="Select" 
                                Height="20px" Width="30px" ImageUrl="~/Images/X.jpg" />
                        </ItemTemplate>
                    </asp:TemplateField>
                
                
                </Columns>
                    <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center"
                        CssClass="myPadd" />
                    <SelectedRowStyle BackColor="Red" ForeColor="GhostWhite" />
                    <HeaderStyle BackColor="Silver" Font-Bold="True" />
                    <EditRowStyle Wrap="False" />
                    <AlternatingRowStyle BackColor="#66CCFF" />
                </asp:GridView>
                </td>
            </tr>
            <tr>
            <td colspan="2"></td>
            </tr>
            <tr>
                <td style="text-align: left">
                    &nbsp;</td>
                <td style="text-align: right">
                    <asp:Button ID="btnSave" runat="server" Text="Save Grid Changes" Visible="false" />
                </td>
            </tr>
        </table>
    </ContentTemplate>
    </asp:UpdatePanel>

Open in new window

0
mgmhicks
Asked:
mgmhicks
2 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
<asp:GridView ID="myGrid" runat="server" AutoGenerateColumns="False" BackColor="#99FFFF"
                    BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ID" ForeColor="Black"
                    GridLines="None" AllowPaging="True" PageSize="25" Width="100%"
                    HeaderStyle-HorizontalAlign="Left" AllowSorting="True"
                        EmptyDataText="No Records Found">

You're not binding the event.
0
 
mgmhicksAuthor Commented:
how would I do that?   The columns are binded and the grid does show the records, its capturing the click event on linkbutton6 that doesn't seem to be working, that ends up doing a postback and then I get a empty grid.  I want to capture that click in code behind.

thanks
0
 
CodeCruiserCommented:
You can use onclick handler for the link button.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now