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

asp.net傳多個值到其它頁面的具體實現(xiàn)

 更新時間:2014年02月21日 16:24:18   作者:  
在頁面之間的跳轉(zhuǎn),經(jīng)常會用到傳值,其中可能會傳遞多個值,下面為大家介紹下asp.net傳多個值到其它頁面的方法,需要的朋友可以參考下
網(wǎng)站開發(fā)中,在頁面之間的跳轉(zhuǎn),經(jīng)常會用到傳值,其中可能會傳遞多個值。

一、CommadArgument傳多個值到其他頁面。
像Gridview dataList repeater等數(shù)據(jù)綁定控件中,可以使用CommadArgument傳多個值。
源的代碼(aspx頁面代碼)如下:這個代碼一般寫在項模板中,如果你用的第一種方法就不需要加上onclick事件,直接點擊數(shù)據(jù)綁定控件的RowCommand ,itemCommand事件,就行了。
復(fù)制代碼 代碼如下:

<asp:ImageButton ID="editImageButton" runat="server" ImageUrl="~/images/bt_edit.gif" CommandArgument='<%#Eval("dict_id")+","+Eval("dict_type")%>' onclick="editImageButton_Click" Height="20" Width="20" />

方法1,如果你用的GridView 控件,找到RowCommand事件雙擊,用的dataList,repeater控件就找到ItemCommand事件雙擊,后臺代碼如下:
復(fù)制代碼 代碼如下:

object[] arg=e.CommandArgument.ToString().split(','); //注意是單引號
string arg0=arg[0].ToString();
string arg1=arg[1].ToString();

方法2,在項模板中放入LinkButton控件。這個比較常用,自己動手給這個控件加上onClick事件。其后臺代碼如下:
復(fù)制代碼 代碼如下:

LinkButton lbt=(LinkButton)sender;
object[] arg=lbt.CommandArgument.ToString.split(',');
string arg0=arg[0].ToString();
string arg1=arg[1].ToString();

二、用超鏈接傳值,也是一種常用的方法
前臺代碼:
復(fù)制代碼 代碼如下:

<a href="Default.aspx?id=<%#Eval("dict_id")%>&type=<%#Eval("dict_type")%>">跳到Default.aspx頁面</a>

后臺:
復(fù)制代碼 代碼如下:

string strDict_id = Request.QueryString["dict_id"];
string strDict_type= Request.QueryString["dict_type"];

相關(guān)文章

最新評論