我想知道在datagridview中遍历所有行并从单元格中获取值的最佳方法是什么.
这是我在想的事情,但我不是很喜欢它,因为如果我重新排列列,那么代码也必须改变.
for (int i = 0; i < dataGridView.RowCount; i++)
{
string Value0 = dataGridView1.Rows[i].Cells[0];
string Value1 = dataGridView1.Rows[i].Cells[1];
string Value2 = dataGridView1.Rows[i].Cells[2];
}
Run Code Online (Sandbox Code Playgroud) 我有一个文件,在我的网站上说PDF,当用户访问页面时,我想在页面加载或按钮点击时显示pdf的下载对话框.
我做了一个谷歌搜索,我找到了两种方法来做到这一点,但想知道这样做的可接受方式是什么?我目前正在这样做
string pdfPath = MapPath("mypdf.pdf");
Response.ContentType = "Application/pdf";
Response.AppendHeader( "content-disposition",
"attachment; filename=" + name );
Response.WriteFile(pdfPath);
Response.End();
Run Code Online (Sandbox Code Playgroud)
(代码基于http://aspalliance.com/259的代码,也可以从http://www.west-wind.com/weblog/posts/76293.aspx找到代码 )
我之前使用过表值参数,但我不确定如何使用xml.
我不知道格式化我的xml的最佳方法,但我想我会试试这个:
<Car>
<Name>BMW</Name>
<Color>Red</Color>
</Car>
Run Code Online (Sandbox Code Playgroud)
然后我会将xml(一个或多个汽车)传递给存储过程,它会为我传递的每辆汽车插入一行(名称将在名称列中等等).
有谁知道如何编写存储过程?(我通常会亲自尝试,但我没有太多时间来测试T_T)