如何在Gridview中单击行时使表可见,主键传入表部分 [英] How Do I Make Table Visible On Click Of Row In Gridview With Primary Key Pass Into Table Section

查看:81
本文介绍了如何在Gridview中单击行时使表可见,主键传入表部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我项目的代码如下所示:

the code for my project is shown below:

<table id="tbljobAction" runat="server" visible="false">
           <tr>
                <td colspan="5">
                    &nbsp; &nbsp; &nbsp; &nbsp;
                    <asp:Button ID="btnStart" runat="server" Text="Start" Width="90px" OnClick="btnStart_Click"

                        CssClass="formbutton" />
                    &nbsp;
                    <asp:Button ID="btnHold" runat="server" Text="Hold" Width="90px" OnClick="btnHold_Click"

                        CssClass="formbutton" />
                    &nbsp;
                    <asp:Button ID="btnEnd" runat="server" Text="End" Width="90px" OnClick="btnEnd_Click"

                        CssClass="formbutton" />
                </td>
            </tr>
    </table>










<table>
<tr id="trGridViewJobList" runat="server" visible="false">
            <td colspan="2">
                <asp:UpdatePanel ID="UpdatePanel_Grid" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:GridView ID="GridViewJobList" runat="server" AutoGenerateColumns="false" CssClass="gridTable"

                            EmptyDataText="No Record Found" DataKeyNames="Entry_No" OnRowDataBound="GridViewJobList_RowDataBound"

                            Width="100%" GridLines="None" AllowPaging="True" PageSize="14" OnPageIndexChanging="GridViewJobList_PageIndexChanging">
                         <Columns>
                                <asp:TemplateField ItemStyle-Width="2%">
                                    <ItemTemplate>
                                        <%#Container.DataItemIndex+1 %>
                                    </ItemTemplate>
                                    <ItemStyle Width="2%" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="Entry_No" HeaderText="Entry No" ItemStyle-Width="7%">
                                    <ItemStyle Width="7%" />
                                </asp:BoundField>
                          <asp:TemplateField HeaderText="Promise Date" ItemStyle-Width="10%">
                                    <ItemTemplate>
                                        <asp:Label ID="lblPromisedDateTime" runat="server" Text='<%# Eval("Promised_Date_Time").ToString()=="1/1/0001 12:00:00 AM"? "":Eval("Promised_Date_Time","{0:MM/dd/yyyy}").ToString() %>'>
                                        </asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="10%" />
                                </asp:TemplateField>
                            </Columns>
                            <PagerSettings PageButtonCount="14" />
                            <PagerStyle BorderWidth="1px" Font-Bold="True" Font-Size="15px" />
                        </asp:GridView>
                        <%--                        <asp:Timer ID="Timer" runat="server" Interval="5000" OnTick="Timer_Tick">
                        </asp:Timer>--%>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
</table>



我想要的是当用户点击gridview中的特定记录时,必须使tbljobAction表可见并输入no (即行的主键)必须传递给按钮的控制..

i使用了使用GridViewJobList_RowDataBound事件的javascript将条目传递给cl方面。我可以使用代码使tbljobAction可见。或任何人都可以帮助我替代方法???


what i want is when user clicks on a particular record in gridview, tbljobAction table must be made visible and entry no (i.e primary key of row) must pass to control of button..
i had used javascript using GridViewJobList_RowDataBound event to pass entry to client side. can i make tbljobAction visible using the code. or can anyone help me on alternate method???

推荐答案

参考我以前的解决方案关于在asp.net中选择行的gridview的火客户端事件 [ ^ ]。

而不是 visible =false,请执行 style =display:none;。因为当你设置Visible为false时,它不会在浏览器上呈现,所以你将无法在客户端做任何事情。



现在进入 JavaScript 函数,尝试删除 display:none

Refer my previous solution fire client side event for gridview on selection of row in asp.net[^].
Instead of doing visible="false", do style="display: none;". Because when you set Visible false, it don't render that on browser, so you won't be able to do anything to that in client side.

Now in that JavaScript function, try to remove the display: none.
function gridRowOnclick(element)
{
    alert("GridView clicked");
    var yourTable = document.getElementById("tbljobAction");
    yourTable.style.display = yourTable.style.display === 'none' ? '' : 'none';
}


这篇关于如何在Gridview中单击行时使表可见,主键传入表部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆