欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net DataGrid控件中彈出詳細(xì)信息窗口

 更新時(shí)間:2008年12月24日 23:53:15   作者:  
在DataGrid控件里單擊某一行的超級鏈接時(shí),彈出一個(gè)新的頁面顯示出該行的詳細(xì)信息
在DataGrid控件中添加超鏈接如下步驟:
(1) 在"設(shè)計(jì)"視圖中,選擇DataGrid控件,然后單擊"屬性"窗口底部的"屬性生成器"鏈接。
(2) 在"DataGrid屬性"對話框中單擊"列"選項(xiàng)卡。
(3) 在"可用列"選項(xiàng)框中,選擇"超級鏈接列"并單擊"添加"按鈕。如下圖進(jìn)行添加超級鏈接列的設(shè)置。

(4) 若要將數(shù)據(jù)字段用作目標(biāo)頁URL的源,請從"URL字段"文本框中填寫該字段名。在這種情況上,可以使用
"URL 格式字符串"選項(xiàng)框?yàn)樵摮夋溄游谋局付ǜ袷皆O(shè)置表達(dá)式。
"URL格式字符口串"目標(biāo)URL為:javascript:varwin=window.open('detail.aspx?ID={0}',null,'width=300,height=200');window.Close();
分別創(chuàng)建兩個(gè)頁面,一個(gè)用來添加DataGrid控件并設(shè)置超級鏈接列,而后者是被彈出的頁面,后者頁面的頁面代碼好下:
<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>
后者頁面的后臺(tái)代碼:
頁面的載入事件
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(!IsPostBack)
{
this.DataGridBind();
}
}
數(shù)據(jù)綁定事件
private void DataGridBind()
{
string EmpID = Request["ID"].ToString();
//調(diào)用Web.config數(shù)據(jù)庫連接字符
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è)置超級鏈接列就可以彈出相應(yīng)行的詳細(xì)信息

相關(guān)文章

最新評論