Solved

Why doesnt gridview row command fire.

Posted on 2014-02-06
3
383 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
3 Comments
 
LVL 39

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now