get row data value& datatable filter & new datatable from datatable
2012-08-03 02:53
495 查看
1. RowDataBound
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DefaultValue = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
}
}
2. Checkbox CheckedChanged Event
protected void ckbBillable_CheckedChanged(object sender, EventArgs e)
{
GridViewRow row = ((GridViewRow)((CheckBox)sender).NamingContainer);
CheckBox ckbBillable = (CheckBox)row.FindControl("ckbBillable");
Guid accountId = new Guid(gvAccountBillable.DataKeys[row.RowIndex]["account_id"].ToString());
// Filter in datatable
DataRow[] rows = dtAccountBillable.Select("account_id='" + accountId + "'");
//Update in View state Data table
if (rows.Length > 0)
{
rows[0]["is_billable"] = ckbBillable.Checked;
}
//if checkbox is checd, change the row color
if (ckbBillable.Checked)
{
row.CssClass = "SelectRowStyle";
}
else
{
row.CssClass = "";
}
}
3. in the button click event
protected void btnSubmit_Click(object sender, EventArgs e)
{
Guid rootAccountID = new Guid(gvAccount.DataKeys[0]["root_account_id"].ToString());
DataView dvAccountBilllingInfo = dtAccountBillable.DefaultView;
// new table just has id and is_billable columns. These two field values are from datatable dtAccountBillable.
DataTable dtAccountBillingUpdate = dvAccountBilllingInfo.ToTable(true, " id", "is_billable");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DefaultValue = ((GridView)sender).DataKeys[e.Row.RowIndex].Value.ToString();
}
}
2. Checkbox CheckedChanged Event
protected void ckbBillable_CheckedChanged(object sender, EventArgs e)
{
GridViewRow row = ((GridViewRow)((CheckBox)sender).NamingContainer);
CheckBox ckbBillable = (CheckBox)row.FindControl("ckbBillable");
Guid accountId = new Guid(gvAccountBillable.DataKeys[row.RowIndex]["account_id"].ToString());
// Filter in datatable
DataRow[] rows = dtAccountBillable.Select("account_id='" + accountId + "'");
//Update in View state Data table
if (rows.Length > 0)
{
rows[0]["is_billable"] = ckbBillable.Checked;
}
//if checkbox is checd, change the row color
if (ckbBillable.Checked)
{
row.CssClass = "SelectRowStyle";
}
else
{
row.CssClass = "";
}
}
3. in the button click event
protected void btnSubmit_Click(object sender, EventArgs e)
{
Guid rootAccountID = new Guid(gvAccount.DataKeys[0]["root_account_id"].ToString());
DataView dvAccountBilllingInfo = dtAccountBillable.DefaultView;
// new table just has id and is_billable columns. These two field values are from datatable dtAccountBillable.
DataTable dtAccountBillingUpdate = dvAccountBilllingInfo.ToTable(true, " id", "is_billable");
}
相关文章推荐
- couldn't get cmd pointer (substituting NULL): extracting data from value failed Couldn't materialize
- easyui 获取数据表格中选中行的数据 Get selected row data from...
- get the return value from the new activity
- couldn't get cmd pointer (substituting NULL): extracting data from value failed Couldn't materialize
- DataTables warning : Requested unknown parameter '1' from the data source for row 0错误
- datatables request unknown parameter '0' from data source for row 0
- To get the "month" from a DATE datatype
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- Data truncation: Out of range value for column '列名' at row 1
- "Unable to get image data from canvas because the canvas has been tainted by cross-origin data"问题产生原
- DataTables warning : Requested unknown parameter '1' from the data source for row 0错误
- easyui 获取数据表格中选中行的数据 Get selected row data from...
- [转] easyui 获取数据表格中选中行的数据 Get selected row data from...
- DataTable && SqlDataReader帮助理解小程序
- 关于Unity 获得和使用GetComponent<MeshFilter>().mesh时的心得
- Cannot get a text value from a numeric cell
- DataTable的Select和DataView的RowFilter语句中注意将字段值中的单引号替换成两个单引号
- Data truncation: Data truncated for column 'xxxxxxxxx' at row 1
- How to get the Values of Selected Row from a Gridview using ASP.NET
- Excel导入异常Cannot get a text value from a numeric cell解决