該網頁是一個公共頁面,它不是由我創建的。大約有 20 個文本框,我想一鍵用特定資料填充它們。關于如何做到這一點的任何想法?
附:幾年前我使用過 asp.net 和 c#,現在我不太記得了。但是提示應該就足夠了,盡管如果您完全指導我將不勝感激。
ps2。看來我應該將代碼寫入我猜的 Windows 應用程式中。
uj5u.com熱心網友回復:
如果您可以滿足于 javascript/typescript,
另一方面,如果我使用這個 sql
string strSQL = "SELECT TOP 4 * FROM tblHotels ORDER by HotelName";
然后我現在得到這個:

因此,如您所見,顯示 1 或 20 個我重復的“東西”不再起作用。我可以說在整個頁面上進行重復,我現在有一個類似卡片視圖的系統。
您當然也可以只撰寫代碼,然后將值推送到文本框中。所以不用說中繼器控制元件,只是他的文本框,那么這將起作用:
string strSQL = "SELECT * FROM tblHotels ORDER by HotelName";
using (SqlCommand cmdSQL = new SqlCommand(strSQL,
new SqlConnection(Properties.Settings.Default.TEST4)))
{
DataTable rstData = new DataTable();
cmdSQL.Connection.Open();
rstData.Load(cmdSQL.ExecuteReader());
DataRow OneRow = rstData.Rows[0];
txtHotelName.Text = OneRow["HotelName"].ToString();
txtFirst.Text = OneRow["FirstName"].ToString();
txtLast.Text = OneRow["LastName"].ToString();
txtCity.Text = OneRow["City"].ToString();
chkActive.Checked = (bool)OneRow["Active"];
}
so you have a lot of options here. And for sure, one will often introudce a model framework (like older datasets, or now EF (entity framework). This gives you a model in code, and thus often you don't have remember the field names, and you get/have a abstracted layer between you and the database.
And most of the data repeating controls are happy to use EF data, or even direct data tables like above shows.
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/354376.html
