Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why doesnt gridview row command fire.

Posted on 2014-02-06
3
Medium Priority
?
401 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 41

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 500 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 500 total points
ID: 39839702
You can use onclick handler for the link button.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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