我应该使用哪种控件来显示这种格式 [英] which control should I Use for display like this formate
问题描述
你好......
我想在这个格式的aspx页面中显示数据。
产品名称手机
数量率:100
单位价格:125
A1 A2 A3 A4总计
红色10 20 30 40 100
蓝色10 20 30 40 100
绿色10 20 30 40 100
总计300
产品名称汽车
数量:120
单位价格:150
B1 B2 B3 B4总计
红色10 20 30 40 100
蓝色10 20 30 40 100
绿色10 20 30 40 100
总计300
总计:600
我有一个具有此值的数据表。
我想在页面中显示但我不知道应该使用哪个控件?
Plz帮助...
那些数据是静态的吗?如果是,请使用简单的html表。如果没有,请创建特定于表的自定义表单。在此,供您参考:
http://weblogs.asp.net/nannettethacker/archive/2008/01/24/html-tables-to-asp-net-table-controls.aspx [ ^ ]
http://www.asp.net/aspnet-in-net-35 -sp1 / videos / how-to-create-table-specific-custom-forms-in-an-aspnet-dynamic-data-application [ ^ ]
祝你好运,
Eduard
引用:我有一个具有此值的数据表。
我想知道你将如何获得所有这些细节一个DataTable。无论如何,您可以尝试使用嵌套GridViews 来完成此操作。我不太确定嵌套其他数据列表控件,如Repeater Control等。
这里有一些CodeProject文章。
可编辑嵌套GridView(多功能一体机)
ASP.NET C#中Gridview内的Gridview
ASP.NET 2.0中的GridView内的Gridview
>
我这将解决上述问题...
//文件后面的代码编写一个函数和调用它在Page Load ...
public void getTable()
{
Table table = new Table();
table.ID =Table1;
table.BorderStyle = BorderStyle.Solid;
Page.Form.Controls.Add(table);
//现在遍历表并添加控件
int totRow = 2;
int totCol = 4;
for(int i = 0; i< totRow; i ++)
{
TableRow row = new TableRow();
for(int j = 0; j< totCol; j ++)
{
TableCell cell = new TableCell();
TextBox tb = new TextBox();
//为每个添加的TextBox设置一个唯一的ID
tb.ID =TextBoxRow_+ i +Col_+ j;
tb.Attributes.Add(runat,Server);
tb.Attributes.Add(OnFocusOut,processText());
//tb.EnableViewState = false;
tb.MaxLength = 128;
HiddenField hf = new HiddenField();
hf.ID =HF_+ i +Col_+ j;
hf.Value =(10 *(i + 1))。ToString();
cell.Controls.Add(hf);
cell.Controls.Add(tb);
//将TableCell添加到TableRow
row.Cells.Add(cell);
}
TableCell celltot = new TableCell();
TextBox tbTot = new TextBox();
tbTot.ID =TotalRow_+ i +Col_+(totCol).ToString();
// tbTot.Attributes.Add(runat,Server);
//tbTot.Attributes.Add(\"OnFocusOut,processText());
//tbTot.EnableViewState = false;
tbTot.MaxLength = 128;
tbTot.ReadOnly = true;
celltot.Controls.Add(tbTot);
row.Cells.Add(celltot);
//将TableRow添加到表
table.Rows.Add(row);
}
TableRow Grow = new TableRow();
Grow.HorizontalAlign = HorizontalAlign.Right;
TableCell Gcelltot = new TableCell();
Label lbl = new Label();
lbl.Text =总计:;
Gcelltot.Controls.Add(lbl);
TextBox GtbTot = new TextBox();
Gcelltot.ColumnSpan = 5;
GtbTot.ID =GTotal;
GtbTot.MaxLength = 128;
GtbTot.ReadOnly = true;
Gcelltot.Controls.Add(GtbTot);
Grow.Cells.Add(Gcelltot);
//将Gcelltot添加到表
table.Rows.Add(Grow);
}
//创建Java脚本赞
function processText(){
var Gtotal = 0;
var totRows = document.getElementById(Table1)。rows.length;
for(var i = 0; i< totRows; i ++){
if(i == totRows - 1){
TBox = document.getElementById(GTotal);
TBox.value = Gtotal;
}
else {
var totCol = document.getElementById(Table1)。rows [i] .cells.length
var total = 0;
for(var j = 0; j< totCol; j ++){
if(j == totCol - 1){
TBox = document.getElementById(TotalRow_+ i + Col_+(totCol - 1));
TBox.value =总;
Gtotal = Gtotal + total;
}
else {
HBox = document.getElementById(HF_+ i +Col_+ j);
var hdata = parseFloat(HBox.value);
if(hdata!= null&& hdata!=){
TBox = document.getElementById(TextBoxRow_+ i +Col_+ j);
var data = TBox.value;
if(data!= null&& data!=){
total = total +(hdata * parseFloat(data));
}
}
}
}
}
}
}
Hello...
I want to display data in aspx page like this format.
Product Name Mobile Qty Rate: 100 Unit Rate: 125 A1 A2 A3 A4 Total Red 10 20 30 40 100 Blue 10 20 30 40 100 Green 10 20 30 40 100 Total 300 Product Name Car Qty Rate: 120 Unit Rate: 150 B1 B2 B3 B4 Total Red 10 20 30 40 100 Blue 10 20 30 40 100 Green 10 20 30 40 100 Total 300 Grand Total: 600
I have one datatable with this value.
I want to display in page but i have't any idea about which control should i use?
Plz Help...
are those data static? if it is, use a simple html table. if not, create a table specific custom forms. Here, for your reference:
http://weblogs.asp.net/nannettethacker/archive/2008/01/24/html-tables-to-asp-net-table-controls.aspx[^]
http://www.asp.net/aspnet-in-net-35-sp1/videos/how-to-create-table-specific-custom-forms-in-an-aspnet-dynamic-data-application[^]
Best regards,
Eduard
Quote:I have one datatable with this value.
I wonder how would you have all these details in one DataTable. Anyways, you may try to do this by using "Nested GridViews". I am not too sure about nesting of other Data-Listing controls like Repeater Control etc.
Here are few CodeProject Articles on this.
Editable Nested GridView (All-in-One)
Gridview inside Gridview in ASP.NET C#
Gridview Inside a GridView in ASP.NET 2.0
I this this will be solve the above Problem...
//Code Behind File Write one Function and Call it in Page Load... public void getTable() { Table table = new Table(); table.ID = "Table1"; table.BorderStyle = BorderStyle.Solid; Page.Form.Controls.Add(table); // Now iterate through the table and add your controls int totRow = 2; int totCol = 4; for (int i = 0; i < totRow; i++) { TableRow row = new TableRow(); for (int j = 0; j < totCol; j++) { TableCell cell = new TableCell(); TextBox tb = new TextBox(); // Set a unique ID for each TextBox added tb.ID = "TextBoxRow_" + i + "Col_" + j; tb.Attributes.Add("runat", "Server"); tb.Attributes.Add("OnFocusOut", "processText()"); //tb.EnableViewState = false; tb.MaxLength = 128; HiddenField hf = new HiddenField(); hf.ID = "HF_" + i + "Col_" + j; hf.Value = (10 * (i+1)).ToString(); cell.Controls.Add(hf); cell.Controls.Add(tb); // Add the TableCell to the TableRow row.Cells.Add(cell); } TableCell celltot = new TableCell(); TextBox tbTot = new TextBox(); tbTot.ID = "TotalRow_" + i + "Col_" + (totCol).ToString(); // tbTot.Attributes.Add("runat", "Server"); //tbTot.Attributes.Add("OnFocusOut", "processText()"); //tbTot.EnableViewState = false; tbTot.MaxLength = 128; tbTot.ReadOnly = true; celltot.Controls.Add(tbTot); row.Cells.Add(celltot); // Add the TableRow to the Table table.Rows.Add(row); } TableRow Grow = new TableRow(); Grow.HorizontalAlign = HorizontalAlign.Right; TableCell Gcelltot = new TableCell(); Label lbl = new Label(); lbl.Text = "Total: "; Gcelltot.Controls.Add(lbl); TextBox GtbTot = new TextBox(); Gcelltot.ColumnSpan = 5; GtbTot.ID = "GTotal"; GtbTot.MaxLength = 128; GtbTot.ReadOnly = true; Gcelltot.Controls.Add(GtbTot); Grow.Cells.Add(Gcelltot); // Add the Gcelltot to the Table table.Rows.Add(Grow); }
// Create Java Script Like
function processText() { var Gtotal = 0; var totRows = document.getElementById("Table1").rows.length; for (var i = 0; i < totRows; i++) { if (i == totRows - 1) { TBox = document.getElementById("GTotal"); TBox.value = Gtotal; } else { var totCol = document.getElementById("Table1").rows[i].cells.length var total = 0; for (var j = 0; j < totCol; j++) { if (j == totCol - 1) { TBox = document.getElementById("TotalRow_" + i + "Col_" + (totCol - 1)); TBox.value = total; Gtotal = Gtotal + total; } else { HBox = document.getElementById("HF_" + i + "Col_" + j); var hdata = parseFloat(HBox.value); if (hdata != null && hdata != "") { TBox = document.getElementById("TextBoxRow_" + i + "Col_" + j); var data = TBox.value; if (data != null && data != "") { total = total + (hdata * parseFloat(data)); } } } } } } }
这篇关于我应该使用哪种控件来显示这种格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!