0
DataList控件:問題的一個DataList事件
<asp:DataList ID="DataList2" runat="server"
DataSourceID="AllQuestionsResponded"
GridLines="Horizontal" DataKeyField="ThreadsID"
onselectedindexchanged="DataList2_SelectedIndexChanged">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">'<%# Eval("ThreadTitle") %>'</asp:LinkButton>
<br />
<br />
</ItemTemplate>
</asp:DataList>
和SQL數據源:
<asp:SqlDataSource ID="AllQuestionsResponded" runat="server"
ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>" SelectCommand="SELECT ThreadTitle, ThreadsID
FROM Threads
WHERE ThreadsID IN (SELECT ThreadsID
FROM Comments
WHERE [email protected])
" onselecting="AllQuestionAskedDataSource_Selecting">
事件背後的代碼:
protected void DataList2_SelectedIndexChanged(object sender, EventArgs e)
{
Server.Transfer("AnswerQuestion.aspx?x=" + DataList2.DataKeyField + "&question=" + DataList2.SelectedValue + "&time=" + DateTime.Now);
}
的事件從未被觸發!無論多少次,我按下按鈕鏈接。爲什麼是:(..
感謝它的工作..但我不能傳遞選定的值..它告訴我,DataList1.SelectedValue.ToString()格式不正確: –
所以這個列可以作爲一個按鈕.cool –