[英]How do I display a table of SQL data on the same page upon form submit in C#?
[英]How Do I Create A Dynamic Form Of Data Populated With SQL Data Based On App Settings In C#
我有帶有SQL Server后端的ac#.net應用程序。 該應用程序根據條形碼記錄公司內部的物料移動。 用戶將他們的項目與用戶一起添加到軟件中,每個用戶均分配有條形碼。 該軟件隨附一個位於牆上的物品跟蹤系統。 系統跟蹤密鑰,例如,有保持100把編碼的鑰匙板,在板上的各位置編號1-100。 在該軟件中,用戶需要能夠看到“虛擬物品板”,該“物品板”顯示在虛擬板上的信息,一目了然地顯示哪個鑰匙在里面,哪個在外面,誰擁有什么等等。
用戶在首次安裝軟件時將軟件編程為正在使用的容量系統,因此該軟件便知道他們正在使用100系統。 我的問題是,如何動態創建表格或某種形式的布局,以網格狀格式顯示此數據? 我已經研究過使用tablelayoutpanel控件,但是它似乎並沒有滿足我的需要。 我在Form_Load事件中具有以下代碼:
private void frmItemBoard_Load(object sender, EventArgs e)
{
try
{
// table data linked to form controls (first 5)
if (Properties.Settings.Default.systemsize == "5" || Properties.Settings.Default.systemsize == "5")
{
// load the layout for a 5 system
}
else if (Properties.Settings.Default.systemsize == "10")
{
// load the layout for a 10 system
}
else if (Properties.Settings.Default.systemsize == "25")
{
// load the layout for a 25 system
}
// etc.....
// other system sizes can go here. The software needs to support at least up to 20,000 keys somehow
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
怎么樣
int size = Properties.Settings.Default.systemsize;
int height = 0;
int width = 0;
//check our sizes
if (size == 5)
{
height = 1;
width = 5;
else if (size == 10)
{
height = 2;
width = 5;
}
else if (size == 25)
{
height = 5;
width = 5;
}
//build a table
string table = "<table>";
for (int i = 1, i<=height,i++)
{
table += "<tr>"
for (int j = 1, j<=width,i++)
{
table += "<td>"
table += "some content"
table += "</td>"
}
table += "</tr>"
}
table += "</table>"
//write table to your page
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.