2011-09-06 35 views

回答

0
Session ('VariableHere') = 'Data'; 
// display variable anywhere on your site 
Out ('Your variable is ' + Session ('VariableHere')); 

我不明白你爲什麼會需要它的會話,會話是針對用戶,你可以使用應用程序變量,因爲我不認爲每個會話都需要它。

0

添加數據鍵你的GridView:

<asp:GridView ID="GridView1" runat="server" DataKeyNames="ItemID" ... > 

值添加到您的單選按鈕(IntelliSense不支持它,但它在那裏):

<asp:RadioButton ID="RadioButton1" runat="server" onclick="radioClick(this);" Value='<%#Container.ItemIndex%>' /> 

在你的JavaScript方法:

radioClick = function(radioCtrl){ 
    __doPostBack("<%=GridView1.UniqueID%>", radioCtrl.value); 
} 

而且RaisePostBackEvent方法添加到您的代碼背後:

protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument) 
{ 
    //call the RaisePostBack event 
    base.RaisePostBackEvent(source, eventArgument); 

    if (source is GridView) 
    { 
     if (source == GridView1) 
     {   
      int itemID = (int)GridView1.DataKeys[Int32.Parse(eventArgument)]["ItemID"];   
     } 
    } 
} 
相關問題