2011-07-02 97 views
0
<%@ Page Title="" Language="C#" MasterPageFile="~/CP.master" AutoEventWireup="true" CodeFile="CP_AllQuestions.aspx.cs" Inherits="CP_AllQuestions" %> 

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 
    <asp:GridView ID="GridView1" runat="server" Height="464px" Width="932px" 
     AutoGenerateColumns="False" DataSourceID="Answered"> 
     <Columns> 
      <asp:BoundField DataField="ThreadTitle" HeaderText="ThreadTitle" 
       SortExpression="ThreadTitle" /> 
     </Columns> 
</asp:GridView> 
    <asp:SqlDataSource ID="Answered" runat="server" 
     ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>" SelectCommand="SELECT ThreadTitle 
FROM Threads AS t 
INNER JOIN Users AS u ON t.UsersID=u.UsersID 
WHERE [email protected]"> 
     <SelectParameters> 
      <asp:Parameter Name="UserID" /> 
     </SelectParameters> 
    </asp:SqlDataSource> 
</asp:Content> 

我想在頁面加載事件時傳遞@UserID。Gridview和傳遞SQL參數

MembershipUser CurrentUser = Membership.GetUser(); 

@UserID = (Guid)CurrentUser.ProviderUserKey; 

但我該怎麼做呢?

回答

1
MembershipUser CurrentUser = Membership.GetUser(); 
Guid userid = (Guid)CurrentUser.ProviderUserKey; 
Answered.SelectParameters.Add("UserID", userid.ToString().Trim()); 
+0

gridview不會出現在頁面上.. why :( – WithFlyingColors