databind from SqlDataSource output to lable or literal

asp.net超難寫的= =......可能是因為不熟吧....

sqlTitle.SelectCommand = "SELECT TOP (1) Name from qqTable where BlockID = 1";
DataView dv = (DataView)sqlTitle.Select(DataSourceSelectArguments.Empty);
DataRowView drv = dv[0];
title.Text = drv["Name"].ToString();

-----------------------------------------------------------------------------------------------

<asp:Literal runat="server" id="title"></asp:Literal>
<asp:SqlDataSource ID="sqlTitle" runat="server" ConnectionString="<%$ ConnectionStrings:ibuypowerConnectionString %>" ></asp:SqlDataSource>

這個範例是從SQL取Name這個欄位的資料到title這個control

http://forums.asp.net/p/1216846/2162150.aspx

沒有留言: