求救~!!!!!~~~对于"如何创建在DataGrid 中使用HyperLinkColumn"出现点小问题,希望解决一下

X27794797 2006-04-09 01:46:22
按照网上的一个例子,自己试着做了一下下,出现点小问题,当我点"查看详细"的连接后,可以连接到WebForm2.aspx,并显示相对应详细数据,但是WebForm1.aspx里面就什么都没有了 页面出现[object],

是一点连接就会出现,是我什么地方写错了吗,
以下是代码WebForm1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="HowTos.DataGrid.PopupWindow.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 360px; POSITION: absolute; TOP: 136px"
runat="server" Width="424px" Height="208px" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="ProductID" HeaderText="ProductID"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" HeaderText="ProductName"></asp:BoundColumn>
<asp:HyperLinkColumn DataNavigateUrlField="ProductID" DataNavigateUrlFormatString="javascript:varwin=window.open('WebForm2.aspx?ProductID={0}',null,'width=692,height=500');"
DataTextField="ProductID" HeaderText="查看详细" DataTextFormatString="查看详细">
<HeaderStyle CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle CssClass="ITEMSTYLEHYPERLINK"></ItemStyle>
</asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</HTML>

//WebForm1.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace HowTos.DataGrid.PopupWindow
{

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;

#region User Defined Code

private void Page_Load(object sender, System.EventArgs e)
{

if ( ! this.IsPostBack )
this.BindData();

}

protected void BindData()
{

SqlCommand cmd = new SqlCommand( "SELECT TOP 10 ProductID, ProductName FROM Products", con("Server=.; DataBase=Northwind;uid=sa;pwd="));
this.DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
this.DataGrid1.DataBind();

}

protected SqlConnection con(System.String ConnectionString )
{

SqlConnection c = new SqlConnection( ConnectionString );
c.Open();
return c;

}

#endregion

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)
{

InitializeComponent();
base.OnInit(e);

}

private void InitializeComponent()
{
this.DataGrid1.PreRender += new System.EventHandler(this.Page_Load);
this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}
}
--------------------------------
//WebForm2.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace HowTos.DataGrid.PopupWindow
{

public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;

#region User Defined Code

private void Page_Load(object sender, System.EventArgs e)
{
if ( ! this.IsPostBack )
this.BindData();
}

protected void BindData()
{
SqlCommand cmd = new SqlCommand( "SELECT * FROM Products WHERE ProductID = @ProductID", con("Server=.; DataBase=Northwind; uid=sa;pwd="));
cmd.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.VarChar, 200));
cmd.Parameters["@ProductID"].Value = Request["ProductID"].ToString();
this.DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
this.DataGrid1.DataBind();
}

protected SqlConnection con(System.String ConnectionString )
{

SqlConnection c = new SqlConnection( ConnectionString );
c.Open();
return c;

}

#endregion

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)
{

InitializeComponent();
base.OnInit(e);

}

private void InitializeComponent()
{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion




}
}

代码基本是参照网上的,希望大虾给菜鸟解决一下,谢谢了


...全文
205 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
X27794797 2006-04-09
  • 打赏
  • 举报
回复
我想要的就是在DataGrid中创建一个弹出式窗口.看网上有例子,就访做了一下,结果就出现上面的问题了
bidisty 2006-04-09
  • 打赏
  • 举报
回复
<asp:HyperLinkColumn DataNavigateUrlField="ProductID" DataNavigateUrlFormatString="javascript:varwin=window.open('WebForm2.aspx?ProductID={0}',null,'width=692,height=500');"

为什么要用window.open?
javascript:去掉可以吗?试试
X27794797 2006-04-09
  • 打赏
  • 举报
回复
运行后我截的图http://bluekevin.go2.icpcn.com/work/1.jpg
点连接后的图http://bluekevin.go2.icpcn.com/work/2.jpg
关掉显示细节那个窗体后的图http://bluekevin.go2.icpcn.com/work/3.jpg
帮我看看 好吗 ?现谢谢了
X27794797 2006-04-09
  • 打赏
  • 举报
回复
没有报错,就是点了之后,出现[object],而不是出现现开始WebForm1.aspx所绑定的数据,我一会截个图吧
califord 2006-04-09
  • 打赏
  • 举报
回复
具体的报错语句是什么?我看了一下感觉是你参数没有设好的事,可能是没有传过来
内容概要:本文针对无刷直流电机驱动的电子机械制动(EMB)执行器,建立了考虑Stribeck摩擦特性的非线性耦合动力学模型,并在Simulink环境完成了系统级仿真分析。研究综合集成了电机动力学、齿轮传动机构与制动执行机构的动力学特性,构建了高保真的机电一体化系统模型。重引入Stribeck摩擦模型以精确描述低速工况下执行器内部存在的静摩擦、粘滞摩擦与库仑摩擦之间的过渡行为,有效提升了系统在启停、反向运动等瞬态过程的动态响应仿真精度。通过多工况仿真验证了模型的有效性,能够准确反映摩擦引起的爬行、滞后与定位误差等非线性现象,为EMB系统的高性能控制算法设计(如摩擦补偿、滑模控制)与结构优化提供了高可信度的仿真平台。; 适合人群:从事汽车电子制动系统、电机驱动控制、机电系统建模与仿真研究的研究生、科研人员及工程技术人员,需具备扎实的机械动力学、自动控制理论基础和MATLAB/Simulink仿真能力。; 使用场景及目标:①用于高精度电子机械制动系统的设计验证与性能预测;②为消除摩擦非线性影响的先进控制策略(如自适应控制、智能控制)提供精确的被控对象模型;③深入探究Stribeck摩擦等非线性因素对系统动态性能(如响应延迟、稳态误差)的作用机理; 阅读建议:读者应结合提供的Simulink模型文件,深入剖析Stribeck摩擦模块的数学实现与参数辨识方法,建议通过改变输入指令(如阶跃、正弦)和负载条件进行对比仿真,以直观理解非线性摩擦对系统动态特性的影响。

62,271

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧