ehappy
c#动态绑定控件

private void Bind()

{

using (OracleDataReader dr = OracleHelper.ExecuteReader("select t.*  from  Youtable t Where  wid=:wid", new OracleParameter[] {

new OracleParameter { OracleType = OracleType.Number, Value = wid, ParameterName = ":wid" }" }

}))

{

if (!dr.Read())

{

Fun.ShowError("数据不存在或已删除!");

}

else

{

ControlCollection controls = Page.Controls;

foreach (var item in controls)

{

if (item.GetType().Name == "Literal")

{

Literal li = (Literal)item;

for (int i = 0; i < dr.FieldCount; i++)

{

if (li.ClientID == dr.GetName(i))

{

li.Text = dr.GetValue(i) + "";

break;

}

}

}

}

}

}

}


粤ICP备18122249号