datagrid中的finddby问题(百分求救)
在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