首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gridview Pop-Up显示以获取更多详细信息

Gridview Pop-Up显示以获取更多详细信息
EN

Stack Overflow用户
提问于 2018-07-23 00:58:47
回答 1查看 737关注 0票数 0

我有一个强大的实体表,"General“。

有两个弱实体表,指向"General";Hardware_Information和"Software_Information";每个弱实体表包含不同的列。

一个Gridview正在展示表格"General“。

问题:如何编写代码,以便当用户单击“常规”网格视图中的一行时,它将追溯到右边的弱实体表,并显示来自弱实体表的信息?

我正在使用ASP.NET C#和Server。

英语不是我的母语,我真的是编程新手。如果我的问题不清楚,但迫切需要帮助的话,请原谅。

EN

回答 1

Stack Overflow用户

发布于 2018-07-26 12:53:59

希望这能帮助您为您的需求编写代码。

使用jQuery显示或显示模式弹出窗口中的网格视图行详细信息,在asp.net中使用c#单击按钮

代码语言:javascript
复制
<link href="http://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
            <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
            <script type="text/javascript">
                function openPopup(productid, productname, price) {
                    $('#lblId').text(productid);
                    $('#lblName').text(productname);
                    $('#lblPrice').text(price);
                    $("#popupdiv").dialog({
                        title: "jQuery Show Gridview Row Details in Popup",
                        width: 300,
                        height: 250,
                        modal: true,
                        buttons: {
                            Close: function () {
                                $(this).dialog('close');
                            }
                        }
                    });
                }
            </script>
            <style type="text/css">
                .GridviewDiv {
                    font-size: 100%;
                    font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helevetica, sans-serif;
                    color: #303933;
                }

                .headerstyle {
                    color: #FFFFFF;
                    border-right-color: #abb079;
                    border-bottom-color: #abb079;
                    background-color: #df5015;
                    padding: 0.5em 0.5em 0.5em 0.5em;
                    text-align: center;
                }
            </style>
            </head>
            <body>
                <form id="form2" runat="server">
                    <div>
                        <div id="popupdiv" title="Basic modal dialog" style="display: none">
                            Product Id:
                            <label id="lblId"></label>
                            <br />
                            Product Name:
                            <label id="lblName"></label>
                            <br />
                            Price:
                            <label id="lblPrice"></label>
                        </div>
                        <table align="center" style="margin-top: 200px">
                            <tr>
                                <td>
                                    <div class="GridviewDiv">
                                        <asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false" Width="420px">
                                            <HeaderStyle CssClass="headerstyle" />
                                            <Columns>
                                                <asp:BoundField DataField="productid" HeaderText="Product Id" />
                                                <asp:BoundField DataField="productname" HeaderText="Product Name" />
                                                <asp:BoundField DataField="price" HeaderText="Price" />
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <a href="#" class="gridViewToolTip" onclick='openPopup("<%# Eval("productid")%>","<%# Eval("productname")%>","<%# Eval("price")%>")'>test</a>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </body>
</html>

      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGridview();
            }
        }
        protected void BindGridview()
        {
            DataSet ds = new DataSet();
            using (SqlConnection con = new SqlConnection("Data Source=Suresh;Integrated Security=true;Initial Catalog=MySampleDB"))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from productinfo", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                con.Close();
                gvDetails.DataSource = ds;
                gvDetails.DataBind();
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51470427

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档