|
(1) 在"設(shè)計(jì)"視圖中,選擇DataGrid控件,然后單擊"屬性"窗口底部的"屬性生成器"鏈接。
(2) 在"DataGrid屬性"對(duì)話框中單擊"列"選項(xiàng)卡。
(3) 在"可用列"選項(xiàng)框中,選擇"超級(jí)鏈接列"并單擊"添加"按鈕。如下圖進(jìn)行添加超級(jí)鏈接列的設(shè)置。

(4) 若要將數(shù)據(jù)字段用作目標(biāo)頁(yè)URL的源,請(qǐng)從"URL字段"文本框中填寫(xiě)該字段名。在這種情況上,可以使用
"URL 格式字符串"選項(xiàng)框?yàn)樵摮?jí)鏈接文本指定格式設(shè)置表達(dá)式。
"URL格式字符口串"目標(biāo)URL為:Javascript:varwin=window.open('detail.ASPx?ID={0}',null,'width=300,height=200');window.Close();
分別創(chuàng)建兩個(gè)頁(yè)面,一個(gè)用來(lái)添加DataGrid控件并設(shè)置超級(jí)鏈接列,而后者是被彈出的頁(yè)面,后者頁(yè)面的頁(yè)面代碼好下:
<form id="Form1" method="post" runat="server">
<FONT face="宋體">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 32px" cellSpacing="0"
cellPadding="1" width="300" border="0">
<TR>
<TD style="WIDTH: 65px">姓名:</TD>
<TD>
<ASP:TextBox id="tbxName" runat="server" Width="184px"></ASP:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 65px">生日:</TD>
<TD>
<ASP:TextBox id="tbxBri" runat="server" Width="184px"></ASP:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 65px">地址:</TD>
<TD>
<ASP:TextBox id="tbxAdd" runat="server" Width="184px"></ASP:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 65px">城市:</TD>
<TD>
<ASP:TextBox id="tbxCity" runat="server" Width="184px"></ASP:TextBox></TD>
</TR>
</TABLE>
</FONT>
</form>
后者頁(yè)面的后臺(tái)代碼:
頁(yè)面的載入事件
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁(yè)面
if(!IsPostBack)
{
this.DataGridBind();
}
}
數(shù)據(jù)綁定事件
private void DataGridBind()
{
string EmpID = Request["ID"].ToString();
//調(diào)用Web.config數(shù)據(jù)庫(kù)連接字符
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionSqlServer"].ToString());
SqlCommand cmd = new SqlCommand("select LastName,FirstName,BirthDate,Address,City from Employees where EmployeeID="+EmpID.ToString(),conn);
conn.Open();
try
{
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
this.tbxName.Text = dr["LastName"].ToString();
this.tbxBri.Text = Convert.ToDateTime(dr["BirthDate"]).ToLongDateString();
this.tbxAdd.Text = dr["Address"].ToString();
this.tbxCity.Text = dr["City"].ToString();
}
}
catch(Exception e)
{
Response.Write(e.ToString());
}
finally
{
conn.Close();
}
}
編譯運(yùn)行點(diǎn)擊設(shè)置超級(jí)鏈接列就可以彈出相應(yīng)行的詳細(xì)信息
AspNet技術(shù):asp.net DataGrid控件中彈出詳細(xì)信息窗口,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。