簡體   English   中英

使用 asp.net c# 將大的 asp.net 控件數據按行插入 sql 表

[英]Insert large asp.net control data row wise into sql table using asp.net c#

下面是我的 46 個 asp.net 控件,包括文本框和下拉列表,用於在單個按鈕中插入數據在此處輸入圖片說明

下面是我的 asp.net 控件 ID,如上圖所示

ddl_tag1    txt_date1   ddl_type1   txt_narration1   txt_amount1     txt_bill1   txt_fromloc1      txt_tolocation1
ddl_tag2    txt_date2   ddl_type2   txt_narration2   txt_amount2     txt_bill2   txt_fromloc2      txt_tolocation2
ddl_tag3    txt_date3   ddl_type3   txt_narration3   txt_amount3     txt_bill3   txt_fromloc3      txt_tolocation3
ddl_tag4    txt_date4   ddl_type4   txt_narration4   txt_amount4     txt_bill4   txt_fromloc4      txt_tolocation4
ddl_tag5    txt_date5   ddl_type5   txt_narration5   txt_amount5     txt_bill5   txt_fromloc5      txt_tolocation5
ddl_tag6    txt_date6   ddl_type6   txt_narration6   txt_amount6     txt_bill6   txt_fromloc6      txt_tolocation6

下面是我的表結構上面六行數據一一插入下面的格式

Sno    TAQ     DATE TYPE   NARRATION   AMOUNT     BILL   FROM LOCATIOM   TO LOCATION

使用添加按鈕插入數據的最佳方法是什么,我必須使用每個循環插入上面的文本框和下拉插入一行然后插入另一行。

如果您手動將一堆控件放在頁面上,而不是將它們數據綁定到任何東西,那么就我所知,創建六個手動插入語句幾乎是唯一的選擇。

正如上面的一位評論者所說,gridview 可能更容易,但老實說,如果重點只是添加而不是顯示/更新(這是 gridviews 最擅長的),我不確定這會給你帶來多少。 如果要求是特別的並且一次只添加六個新行,那么您可能正在做最簡單的事情。

如果您最終想要更多的功能而不僅僅是添加記錄,您可能需要查看 gridview。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM