C# Gridview弹出窗口显示更多详细信息
我有一个强大的实体表“General” 有两个指向“一般”的弱实体表; “硬件信息”和“软件信息”;每个弱实体表包含不同的列 Gridview显示了表格“General” 问题:如何编码,以便当用户单击“常规”gridview中的一行时,它将追溯到右侧的弱实体表,并显示弱实体表中的信息? 我正在使用ASP.NET C#和SQL ServerC# Gridview弹出窗口显示更多详细信息,c#,sql,asp.net,sql-server,C#,Sql,Asp.net,Sql Server,我有一个强大的实体表“General” 有两个指向“一般”的弱实体表; “硬件信息”和“软件信息”;每个弱实体表包含不同的列 Gridview显示了表格“General” 问题:如何编码,以便当用户单击“常规”gridview中的一行时,它将追溯到右侧的弱实体表,并显示弱实体表中的信息? 我正在使用ASP.NET C#和SQL Server 英语不是我的母语,我真的是编程高手。如果我的问题不清楚,我深表歉意,但非常需要帮助。希望这能帮助您根据自己的要求编写代码 使用jQuery在asp.net中
英语不是我的母语,我真的是编程高手。如果我的问题不清楚,我深表歉意,但非常需要帮助。希望这能帮助您根据自己的要求编写代码 使用jQuery在asp.net中使用c在按钮单击的模式弹出窗口中显示或显示gridview行详细信息#
函数openPopup(产品ID、产品名称、价格){
$('#lblId').text(productid);
$('#lblName').text(产品名称);
$('lblPrice')。文本(价格);
$(“#popupdiv”)。对话框({
标题:“jQuery在弹出窗口中显示Gridview行详细信息”,
宽度:300,
身高:250,
莫代尔:是的,
按钮:{
关闭:函数(){
$(this.dialog('close');
}
}
});
}
.GridviewDiv{
字体大小:100%;
字体系列:“Lucida Grande”、“Lucida Sans Unicode”、Verdana、Arial、Helevetica、Sans serif;
颜色:#303933;
}
.头式{
颜色:#FFFFFF;
右边框颜色:#abb079;
边框底色:#abb079;
背景色:#df5015;
填充:0.5em 0.5em 0.5em 0.5em;
文本对齐:居中;
}
产品标识:
产品名称:
价格:
受保护的无效页面加载(对象发送方、事件参数e)
{
如果(!IsPostBack)
{
BindGridview();
}
}
受保护的void BindGridview()
{
数据集ds=新数据集();
使用(SqlConnection con=newsqlconnection(“数据源=Suresh;集成安全性=true;初始目录=MySampleDB”))
{
con.Open();
SqlCommand cmd=newsqlcommand(“从productinfo中选择*”,con);
SqlDataAdapter da=新的SqlDataAdapter(cmd);
da.填充(ds);
con.Close();
gvDetails.DataSource=ds;
gvDetails.DataBind();
}
}
决定正确的弱实体表的逻辑是什么?@ChetanRanpariya嗨,谢谢你的时间。“General”表有主键。“General”中的每个主键唯一地标识“Hardware\u information”和“Software\u information”中的一行信息。弱实体表,“Hardware\u information”和“软件信息”有不同的数据列,因此数据是不同的。假设“常规”中的PK运行数字“1”和“2”。“1”将指向“硬件信息”中的一行;而“2”将指向“软件信息”中的一行。我不能在弱实体表中使用FK,因为它是一对一的关系。
<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();
}
}