在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

解决方案 »

  1.   

    // C#
    dsCategories.CategoriesRow r;
    r = dsCategories1.Categories.FindByCategoryID(int.Parse(key));看样子,应该是作者自定义的类嘛。dsCategories继承于DataSet。自己定义了一个FindBy方法。
      

  2.   

    生成数据集 从“数据”菜单中选择“生成数据集”。 
    提示   如果未启用“生成数据集”命令,则单击该页;该页必须具有焦点,命令才会出现。
    出现“生成数据集”对话框。 选择“新建”选项,将该数据集命名为 dsCategories。 
    在“选择要添加到数据集中的表”下面的列表中,确保选择了 Categories 表。 确保“将此数据集添加到设计器”已选中,然后单击“确定”。 
    Visual Studio 生成某类型化数据集类 (dsCategories) 和定义该数据集的架构。您将在解决方案资源管理器中看到新的架构 (dsCategories.xsd)。 提示   在“解决方案资源管理器”中,单击“显示所有文件”工具栏按钮以查看架构文件的相关 .vb 或 .cs 文件,该文件包含定义新数据集类的代码。
    最后,Visual Studio 将新数据集类 (dsCategories1) 的实例添加到页上。 此刻,为执行从数据库获取信息并转移到数据集的操作所需的全部设置均已完成。