How to get the imgbtnView image button in gridview to display the row of data? i try to use modelpopupextender but the targetid is invalid because the image button is in the gridview. when click on imgbtnView, solistPanel will be display now i cant display the solistPanel. please help

<table cellpadding="5" cellspacing="5">
        <tr>
            <td>
                <asp:GridView ID="outstandingList" runat="server" CellPadding="2" AutoGenerateColumns="False" DataKeyNames="Cust_No" DataSourceID="outstandingList_SqlDataSource" AllowPaging="True" EmptyDataText="No Outstanding Found" PageSize="20">
                    <Columns>
                        <asp:BoundField DataField="Cust_No" HeaderText="Customer No" SortExpression="Cust_No" />
                        <asp:BoundField DataField="Cust_Name" HeaderText="Customer Name" SortExpression="Cust_Name" />
                        <asp:BoundField DataField="Cust_CreditLimit" HeaderText="Credit Limit" SortExpression="Cust_CreditLimit" />           
                        <asp:BoundField DataField="Total Cost" HeaderText="Total Cost" SortExpression="Total Cost" />               
                        <asp:BoundField DataField="Outstanding" HeaderText="Outstanding" SortExpression="Ouststanding" />
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:ImageButton ID="imgbtnView" runat="server" CommandArgument='<%#EVAL("Cust_No") %>' ImageUrl="~/Image/view.gif" />
                                <asp:Button ID="test" runat ="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>

                </asp:GridView>
                <asp:SqlDataSource ID="outstandingList_SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:PoInvoiceConnectionString %>"
                    SelectCommand="SELECT Master_Customer.Cust_No,Master_Customer.Cust_Name,Master_Customer.Cust_CreditLimit,SUM(SO_Detail.SOD_Cost*SO_Detail.SOD_Qty) AS [Total Cost], Master_Customer.Cust_CreditLimit-Master_Customer.Cust_Outstanding-SUM(SO_Detail.SOD_Cost*SO_Detail.SOD_Qty)AS [Outstanding] FROM SO_Main JOIN Master_Customer ON master_customer.CUst_id=so_main.SO_custID JOIN SO_Detail ON SO_Detail.SOD_SOID=SO_Main.SO_ID GROUP BY Master_Customer.Cust_No,Master_Customer.Cust_Name ,Master_Customer.Cust_Outstanding, Master_Customer.Cust_CreditLimit HAVING Master_Customer.Cust_CreditLimit-Master_Customer.Cust_Outstanding-SUM(SO_Detail.SOD_Cost*SO_Detail.SOD_Qty)<0 "> 
                    <SelectParameters>
                        <asp:Parameter Name="SO_SP" />      
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>



    <asp:Panel ID="solistPanel" runat="server" BackColor="white" BorderColor="Black" BorderStyle="Double" width="5" Visible ="false" >
        <table cellpadding="5" cellspacing="5">
        <tr>
            <td> <h4>SO List of Outstanding Customer</h4>
                <asp:GridView ID="solist" runat="server" CellPadding="2" AutoGenerateColumns="False" DataKeyNames="SO_No" DataSourceID="solist_SqlDataSource" AllowPaging="True" EmptyDataText="NO DATA" PageSize="10">
                    <Columns>   
                        <asp:BoundField DataField="Customer" HeaderText="Customer" SortExpression="Customer" />
                        <asp:BoundField DataField="SO_No" HeaderText="SO No" SortExpression="SO_No" />           
                        <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" />               
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:ImageButton ID="imgbtnApprove" runat="server" CommandArgument ='<%#EVAL("SO_No") %>'  height="20px" Width="25px" ImageUrl="~/Image/up.png" ToolTip ="Approve SO" OnClientClick ="imgbtnApprove_Click" />
                                <asp:ImageButton ID="imgbtnReject" runat="server" CommandArgument ='<%#EVAL("SO_No") %>'  height="20px" Width="25px" ImageUrl="~/Image/down.png" ToolTip ="Reject SO" OnClientClick ="imgbtnReject_Click"/>
                                <asp:ImageButton ID="imgbtnEmail" runat="server" CommandArgument ='<%#EVAL("SO_No") %>'  height="20px" Width="25px" ImageUrl="~/Image/email.png" ToolTip ="Send email to customer to increase credit"  />
                                <asp:HiddenField ID="hfEmail" runat="server" Value='<%#EVAL("SO_No") %>'/>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="solist_SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:PoInvoiceConnectionString %>"
                    SelectCommand="SELECT (Master_Customer.Cust_No +' '+ Master_Customer.Cust_Name) AS Customer, SO_Main.SO_No, CAST(SUM(SO_Detail.SOD_Cost*SO_Detail.SOD_Qty) AS DECIMAL(18,2)) AS [Total] FROM SO_Main JOIN Master_Customer ON Master_Customer.Cust_ID=SO_Main.SO_CustID JOIN SO_Detail ON SO_Detail.SOD_SOID=SO_Main.SO_ID WHERE SO_Detail.SOD_Status='PENDING' AND Master_Customer.Cust_No='S001' GROUP BY SO_Main.SO_No,Master_Customer.Cust_No,Master_Customer.Cust_Name, Master_Customer.Cust_CreditLimit,Master_Customer.Cust_Outstanding HAVING Master_Customer.Cust_CreditLimit-Master_Customer.Cust_Outstanding-SUM(SO_Detail.SOD_Cost*SO_Detail.SOD_Qty)<0 ">
                    <SelectParameters>
                        <asp:Parameter Name="SO_No" />      
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>   
    </table>
    </asp:Panel>

Hi,
I'm a bit rusty at this but here goes, in your code the buttons are being dynamically created based on the database records so you have to specify which sub routine to run on each button that takes the command arguments and uses them. i.e. you can not rely on a imgbtnApprove_onclick automatically handling the imgbtnApprove click event because there are multiple imgbtnApprove's created on the fly by the results of your query. You must specify in the buttons OnCommand property to use the "imgbtnApprove_onclick" sub routine. Then in the Sub routine you can use your Command argument property to identify what is being approved:

<asp:ImageButton ID="imgbtnApprove" CommandArgument='<%#EVAL("SO_No")%>' OnCommand="imgbtnApprove_OnClick" />
.....

Sub imgbtnApprove_OnClick(byval Sender as object, ByVal e as CommandEventArgs)
Dim SO_NO as integer = e.CommandArgument
'do what ever....
End Sub

Also, if you use the CommandName property you could have one routine handle all the approve reject and email buttons:

Sub imgBtn_OnClick(byval sender as object, byval e as CommandEventArgs)
dim Action as String = e.CommandName
dim So_No as integer = e.CommandArgument
Select Action
    case "Approve"
        'approve the record
    case "Reject"
        'Reject the record
    Case Else
        'Email?
End Select
End Sub

the answer you posted is the question i has not raise yet but thanks for giving ahead start.. before i could reach the approve,reject or email routine, i need to display the panel from imgbtnView.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.