【问题标题】:Gridview Pop-Up display for more detail informationGridview 弹出显示以获取更多详细信息
【发布时间】:2018-07-23 00:58:47
【问题描述】:

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

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

Gridview 正在显示“常规”表。

问题:如何编码,当用户在“General”gridview中点击一行时,它会回溯到右边的弱实体表,并显示来自弱实体表的信息?

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

英语不是我的母语,我真的是编程菜鸟。如果我的问题不清楚但迫切需要帮助,我们深表歉意。

【问题讨论】:

  • 判断right weak entity table的逻辑是什么?
  • @ChetanRanpariya 您好,感谢您抽出宝贵时间。 “General”表有主键。 “General”中的每个主键唯一标识“Hardware_Information”和“Software_Information”中的一行信息。
  • 弱实体表“Hardware_Information”和“Software_Information”的数据列不同,因此数据不同。假设“General”中的PK是流水号,“1”和“2”。 “1”将指向“Hardware_Information”中的一行;而“2”将指向“Software_Information”处的一行。我不能在弱实体表中使用 FK,因为它是一对一的关系。

标签: c# sql asp.net sql-server


【解决方案1】:

希望这可以帮助您根据您的要求进行编码。

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

<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();
            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多