在SDK文档里有一个示例,其中使用了下面的语句,第二条语句提求没有FindByCategoryID(key)这个方法,难道SDK文档也有错?3、在数据表中查找对应的行。类型化的 dsCategories 数据集包含一个特殊的 FindBy 方法(在本例中为 FindByCategoryID 方法),该方法通过行的主键定位行并返回一个对它的引用。创建类型化数据行的变量并调用该方法: dsCategories.CategoriesRow r;
r = DsCategories1.Categories.FindByCategoryID(key);完整示例如下:
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string categoryName, categoryDescription; string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb;
tb = (TextBox)(e.Item.Cells[2].Controls[0]);
categoryName = tb.Text;
tb = (TextBox)(e.Item.Cells[3].Controls[0]);
categoryDescription = tb.Text; dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Parse(key)); // Updates the dataset table.
r.CategoryName = categoryName;
r.Description = categoryDescription; // Calls a SQL statement to update the database from the dataset
sqlDataAdapter1.Update(dsCategories1); // Takes the DataGrid row out of editing mode
DataGrid1.EditItemIndex = -1; // Refreshes the grid
DataGrid1.DataBind();http://search.csdn.net/Expert/topic/1590/1590699.xml?temp=.8043024
基本上上上面这个说的是一个问题
不过我没看懂怎么回事楼主就结帖子了
msnd中的例子如下
http://msdn.microsoft.com/library/chs/default.asp?url=/library/chs/vbcon/html/vbwlkwalkthroughusingdatagridwebcontroltoreadwritedata.asp里面也用到了findby
r = DsCategories1.Categories.FindByCategoryID(key);完整示例如下:
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string categoryName, categoryDescription; string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb;
tb = (TextBox)(e.Item.Cells[2].Controls[0]);
categoryName = tb.Text;
tb = (TextBox)(e.Item.Cells[3].Controls[0]);
categoryDescription = tb.Text; dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Parse(key)); // Updates the dataset table.
r.CategoryName = categoryName;
r.Description = categoryDescription; // Calls a SQL statement to update the database from the dataset
sqlDataAdapter1.Update(dsCategories1); // Takes the DataGrid row out of editing mode
DataGrid1.EditItemIndex = -1; // Refreshes the grid
DataGrid1.DataBind();http://search.csdn.net/Expert/topic/1590/1590699.xml?temp=.8043024
基本上上上面这个说的是一个问题
不过我没看懂怎么回事楼主就结帖子了
msnd中的例子如下
http://msdn.microsoft.com/library/chs/default.asp?url=/library/chs/vbcon/html/vbwlkwalkthroughusingdatagridwebcontroltoreadwritedata.asp里面也用到了findby
解决方案 »
- asp.net 和access 做的一个 gridview 操作数据的,删除数据页面更新慢
- js动态变换标题的举动是否利于收录吗?
- ajax的问题
- IIS外挂,共享知识
- 如何生级我的D版 WINDDOS2003
- DataGrid分页的问题 没有分了请各位大哥帮帮忙把
- Excel.ApplicationClass()的问题
- asp.net的三层架构
- ButtonColumn与datagrid的SelectedIndexChanged事件问题,up者有分
- asp.net+SQl 大神求帮助。帮我看看下面这段代码
- 才安好.net测试环境,那位给我一段测试.net运行环境是否安装好的代码??
- 有两个解决方案的asp.net程序可以用一个安装包部署吗?该怎样作?
dsCategories.CategoriesRow r;
r = dsCategories1.Categories.FindByCategoryID(int.Parse(key));看样子,应该是作者自定义的类嘛。dsCategories继承于DataSet。自己定义了一个FindBy方法。
提示 如果未启用“生成数据集”命令,则单击该页;该页必须具有焦点,命令才会出现。
出现“生成数据集”对话框。 选择“新建”选项,将该数据集命名为 dsCategories。
在“选择要添加到数据集中的表”下面的列表中,确保选择了 Categories 表。 确保“将此数据集添加到设计器”已选中,然后单击“确定”。
Visual Studio 生成某类型化数据集类 (dsCategories) 和定义该数据集的架构。您将在解决方案资源管理器中看到新的架构 (dsCategories.xsd)。 提示 在“解决方案资源管理器”中,单击“显示所有文件”工具栏按钮以查看架构文件的相关 .vb 或 .cs 文件,该文件包含定义新数据集类的代码。
最后,Visual Studio 将新数据集类 (dsCategories1) 的实例添加到页上。 此刻,为执行从数据库获取信息并转移到数据集的操作所需的全部设置均已完成。