今天想把一個Table傳入StoredProcedure時查到這篇部落格資料,才知道要自己去定義自己的TableType指明有哪些欄位才可使用,而且是readonly
寫得蠻清楚的,讓小弟受益良多
網址
http://paladinprogram.blogspot.com/2011/03/sql-2008-table-value-parameters-tvp.html
public T FindControl<T>(string id)
where T : Control
{
return FindControl<T>(Page, id);
}
public static T FindControl<T>(Control startingControl, stringid)
where T : Control
{
// 取得 T 的預設值,通常是 null T found = default(T);
int controlCount = startingControl.Controls.Count;
if (controlCount > 0)
{
for (int i = 0; i < controlCount; i++)
{
Control activeControl = startingControl.Controls[i];
if (activeControl is T)
{
found = startingControl.Controls[i] as T;
if (string.Compare(id, found.ID, true) == 0)break;
else found = null;
}
else
{
found = FindControl<T>(activeControl, id);
if (found != null) break;
}
}
}
return found;
}