Solved

Why doesnt gridview row command fire.

Posted on 2014-02-06
3
396 Views
Last Modified: 2014-02-06
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
Comment
Question by:mgmhicks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 250 total points
ID: 39839044
<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
 

Author Comment

by:mgmhicks
ID: 39839113
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
ID: 39839702
You can use onclick handler for the link button.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question