绑定事件的话在RowDataBound里面写
解决方案 »
- 可否在richtextbox/textbox里想Console.WriteLine()一样的输出
- 使用tcpclient向tcp端口下发数据帧问题。
- 关于三角形角度计算的问题(数学知识不行啊) 求救!!
- 如何解决:现运行的工作流和已经持久化的工作流间的“版本差异”
- MET
- 怎么在代码中设置dataGridView中的某个单元格为选定状态?
- udp如何 接收 大量 数据
- 用SqlDataAdapter更新方式效率怎么样?各位能不能给一个完整的代码
- DataGrid键盘事件处理问题~~~~~~~~~~~~~~~
- c# 咨询关于计算预计提货时间的思路
- 高分求助:asp.net(c#)中文件下载问题
- c# 禁止同時打開同一窗體??
public static int BindGridView(GridView gridview, string connnectionString, string commandString)
{
SqlConnection conn = new SqlConnection(connnectionString);
conn.Open();
SqlCommand comm = new SqlCommand(commandString, conn);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = comm;
DataSet dataset = new DataSet();
int count = 0;
try
{ adapter.Fill(dataset, "table");
count = dataset.Tables["table"].DefaultView.Count;
gridview.DataSource = dataset.Tables["table"].DefaultView;
gridview.DataBind(); for (int i = 0; i < gridview.Rows.Count; i++)
{
for (int y = 0; y < gridview.Rows[i].Cells.Count; y++)
{
if (gridview.Rows[i].Cells[y].Text == "False")
{
gridview.Rows[i].Cells[y].Text = "否";
}
if (gridview.Rows[i].Cells[y].Text == "True")
{
gridview.Rows[i].Cells[y].Text = "是";
}
}
}
}
finally
{ conn.Close(); }
return count;
}
{
for (int y = 0; y < gridview.Rows[i].Cells.Count; y++)
{
if (gridview.Rows[i].Cells[y].Text == "False")
{
gridview.Rows[i].Cells[y].Text = "否";
}
if (gridview.Rows[i].Cells[y].Text == "True")
{
gridview.Rows[i].Cells[y].Text = "是";
}
}
}