隐藏来自SQL查询的.aspx页中的列
本文关键字:aspx 查询 SQL 隐藏 | 更新日期: 2024-10-23 15:21:27
我编写了SQL存储过程选择代码[代码]发件人----其中---
现在,出于某种条件,我想要那个代码列,但出于某些条件,我不想要那个。我怎样才能做到这一点?
代码:-
DataTable dtOutput= /Some function which return Datatable (accpet parameters as well for selection)
Table tOutput = / Some Function Which Converts Datatable to Table (For displaying it in HTML)
if (sTicketStatus == "0")
{
// Normal Statement which select all column coming from sql stored procedure
}
else
{
foreach (TableRow trOutput in tOutput.Rows)
{
// What to write Here ?
}
}
Page.Controls.Add(tOutput);
dtOutput.Columns.Remove(dtOutput.Columns["ColumnName"]);
请尝试此代码,此代码用于删除列。
使用
DataTable.DefaultView.ToTable(false, string_array_of_desire_columns[])
您可以使用View来选择特定的列。。。
dt.DefaultView.ToTable(false, "Column1", "Column2");
如果您想要不同的recod,请将第一个参数发送为True。。。请参考http://msdn.microsoft.com/en-us/library/wec2b2e6.aspx