编辑记录时 绑定记录DATATABLE到页面控件
2012-06-08 12:23
246 查看
private void addrecord_Load(object sender, EventArgs e)
{
if (this.editid != 0)
{
rec r = new rec();
DataTable dt = r.queryByid(editid);
Bind(dt);
}
}
private void Bind(DataTable dt)
{
DataRow dr = dt.Rows[0];
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn dc = dt.Columns[i];
bindTextboxValue(dc.ColumnName, dr[i].ToString());
}
//foreach (DataColumn dc in dr)
//{
// dc.ToString();
//}
// if (dt.Rows.Count == 0) return true;
}
private void bindTextboxValue(string name, string value)
{
foreach (Control con in this.Controls)
{
// if (!con.HasControls)
if (con is GroupBox)
{
foreach (Control con2 in con.Controls)
{
if (con2 is TextBox)
{
if (con2.Name.Equals(name))
con2.Text = value;
}
//
}
}
}
}
//bindTextboxValue
{
if (this.editid != 0)
{
rec r = new rec();
DataTable dt = r.queryByid(editid);
Bind(dt);
}
}
private void Bind(DataTable dt)
{
DataRow dr = dt.Rows[0];
for (int i = 0; i < dt.Columns.Count; i++)
{
DataColumn dc = dt.Columns[i];
bindTextboxValue(dc.ColumnName, dr[i].ToString());
}
//foreach (DataColumn dc in dr)
//{
// dc.ToString();
//}
// if (dt.Rows.Count == 0) return true;
}
private void bindTextboxValue(string name, string value)
{
foreach (Control con in this.Controls)
{
// if (!con.HasControls)
if (con is GroupBox)
{
foreach (Control con2 in con.Controls)
{
if (con2 is TextBox)
{
if (con2.Name.Equals(name))
con2.Text = value;
}
//
}
}
}
}
//bindTextboxValue
相关文章推荐
- 编辑记录时 绑定记录DATATABLE到页面控件
- Repeater控件的应用 MyOrders页面绑定数据,编辑,删除
- ASP.net服务器控件页面跳转兼GirdView数据绑定控件动态传值
- GridView控件常见问题及处理方法===1. 关于隐藏字段的处理:==2. 关于按钮列的事件:==3. 关于按钮的客户端提示:==4. 关于时间字段的格式化输出:==5. 关于绑定空记录:
- Web页面折线图控件(可以直接绑定数据)
- C# Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面
- 每日学习总结:DataTable按某一列数值大小排序问题、GridView后台动态绑定、页面导航方法总结
- DataGridView 绑定DataTable方式编辑保存的bug?
- DeltaOffice在线编辑控件HTML页面示例程序
- GridView绑定DataSet的DataTable,怎么让它在无记录时能显示表头呀(环境VS2005),在线等 谢谢!!
- .NET中LinkButton控件进行数据绑定,页面跳转并传值
- iOS如何绑定控件事件(学习记录)
- GridView通过Container在前台页面访问并找到绑定模版中控件
- 每日学习总结:DataTable按某一列数值大小排序问题、GridView后台动态绑定、页面导航方法总结
- 在编辑页面布局,点击其中的一个控件时,不自动定位到页面的代码
- BS将form中的控件这只成只能编辑和jquery绑定事件并传递参数
- Discuz! X3.2学习记录:多数据记录页面增加分页控件
- BootStrap 智能表单系列 六 表单数据绑定(编辑页面的数据绑定)
- DropDownList绑定出现控件中显示的是“System.Data.DataRowView”问题记录
- DataGridView绑定 DataTable 编辑的问题