?
Solved

Why doesnt gridview row command fire.

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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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