<asp:HyperLinkColumn DataNavigateUrlField="id" DataNavigateUrlFormatString=view.aspx?id={0} DataTextField="详细地址" SortExpression="title" HeaderText="详细地址"></asp:HyperLinkColumn><asp:HyperLinkColumn DataNavigateUrlField="id" DataNavigateUrlFormatString=view.aspx?id={0} Text="详情" SortExpression="title" HeaderText="详情"></asp:HyperLinkColumn>
<HeaderStyle Font-Bold="True"></HeaderStyle>
<ItemStyle Width="150px"></ItemStyle>
<ItemTemplate>
<a href='items.aspx?id=<%# DataBinder.Eval(Container.DataItem, "Name") %>'Item</a>
</ItemTemplate>
</asp:TemplateColumn>
using System.Collections;
using System.ComponentModel;
using System.Data;
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 JBInfoManage._2052.ASPX.Analy
{
/// <summary>
/// Analy 的摘要说明。
/// </summary>
public class Analy : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox txtErr;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.CheckBoxList CheckBoxList1;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox txtTel;
protected System.Web.UI.WebControls.TextBox txtMobile;
protected System.Web.UI.WebControls.DataGrid grd1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
this.FillGrid(0,"","","");
}
}
#region FillGrid(int page ,string pStart,string pEnd)
/// <summary>
/// 填充DATAGRID
/// </summary>
/// <param name="page">当前页</param>
private void FillGrid(int page ,string pStart,string pEnd,string pName)
{
JBInfoBase.RegSet pRS=new JBInfoBase.RegSet();
DataTable pDT=pRS.GetAnaly(pStart,pEnd);
DataView pdv=pDT.DefaultView;
//过滤条件
pdv.RowFilter=pName;
this.grd1.DataSource=pdv;
this.grd1.CurrentPageIndex=page;
this.grd1.DataBind();
foreach(DataGridItem item in grd1.Items )
{
for(int i=1;i<4;i++)
{
//跳到指定页
item.Cells[i].Attributes.Add("onclick","javascript:self.location.href='Sign.aspx?Change=1&BillID="+ ((CheckBox)item.Cells[0].Controls[1]).ToolTip.ToString() +"'");
item.Cells[i].Attributes.Add("Style","cursor:hand;");
}
((HyperLink)item.Cells[8].Controls[1].FindControl("btledit")).Attributes.Add("onclick","javascript:self.location.href='Sign.aspx?Change=1&BillID="+ ((CheckBox)item.Cells[0].Controls[1]).ToolTip.ToString() +"'");
((HyperLink)item.Cells[8].Controls[1].FindControl("btledit")).Attributes.Add("Style","cursor:hand;");
string pGuid=((CheckBox)item.Cells[4].Controls[1].FindControl("CheckBox1")).ToolTip.ToString();
if(pGuid=="")
{
((HyperLink)item.Cells[4].Controls[1].FindControl("hPTel")).Visible=false;
}
else
{
((HyperLink)item.Cells[4].Controls[1].FindControl("hPTel")).Attributes.Add("onclick","javascript:OpenWin(1,'"+pGuid+"')");
((HyperLink)item.Cells[4].Controls[1].FindControl("hPTel")).Attributes.Add("Style","cursor:hand;");
((CheckBox)item.Cells[4].Controls[1].FindControl("CheckBox1")).Checked=true;
}
((CheckBox)item.Cells[4].Controls[1].FindControl("CheckBox1")).Enabled=false;
((CheckBox)item.Cells[5].Controls[1].FindControl("CheckBox2")).Enabled=false;
((CheckBox)item.Cells[6].Controls[1].FindControl("CheckBox3")).Enabled=false;
((CheckBox)item.Cells[7].Controls[1].FindControl("CheckBox4")).Enabled=false;
string pGuid2=((CheckBox)item.Cells[5].Controls[1].FindControl("CheckBox2")).ToolTip.ToString();
if(pGuid2=="")
{
((HyperLink)item.Cells[5].Controls[1].FindControl("imgPFace")).Visible=false;
}
else
{
((HyperLink)item.Cells[5].Controls[1].FindControl("imgPFace")).Attributes.Add("onclick","javascript:OpenWin(2,'"+pGuid2+"')");
((HyperLink)item.Cells[5].Controls[1].FindControl("imgPFace")).Attributes.Add("Style","cursor:hand;");
((CheckBox)item.Cells[5].Controls[1].FindControl("CheckBox2")).Checked=true;
}
可以结的呀
DataNavigateUrlField="id"
DataNavigateUrlFormatString=detial.aspx?id={0}
Text="详情"HeaderText="详情"/>
在另外一個葉面就可以用Request["id"]來接受id 號碼
然後可以從數據庫中找出一條記錄來 單獨顯示就可以了
這裡面id={0}是個表達式 在執行的時候{0} 會被替換為id 的值