我在一页上有两个gridview..我列出了第一个而不是commandargument(“id”)我列出了第二个..但是我在这些gridviews上做一些我可以完成第一个gridview,因为没有必要捕获 id 以列出它。它列出了它所拥有的一切。但第二个,我只想列出该产品的类别 ID。你能帮助我吗 ?以及词语的翻译;
Doldur:填充/ Guncelle:更新/ Sil:删除/ vazgec:取消
错误的地方充满了问号。谢谢你的帮助
private void Doldur()
{
WebHelper.FillGridView(myGrid, Service.GetAllCategories());
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;
Doldur();
}
protected void myGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = null;
if (e.CommandSource is ImageButton)
{
row = ((e.CommandSource as ImageButton).NamingContainer) as GridViewRow;
}
int id = 0;
int.TryParse(e.CommandArgument.ToString(), out id);
switch (e.CommandName)
{
case "sil":
Service.Sil(id);
break;
case "guncelle":
// textbox'ı yakalamak için
TextBox txtKategoriAd = myGrid.Rows[row.RowIndex].FindControl("txtKategoriAd") as TextBox;
var kategori = new Categories { CategoryID = id, CategoryName = txtKategoriAd.Text };
Service.Update(kategori);
// Edit moddan çıkılmalı..
myGrid.EditIndex = -1;
break;
case "vazgec":
myGrid.EditIndex = -1;
break;
case "link":
int categoryId = Convert.ToInt32(e.CommandArgument);
myGrid2.DataSource = Service.GetProductsByCategories(categoryId);
myGrid2.DataBind();
break;
}
Doldur();
}
protected void myGrid_RowEditing(object sender, GridViewEditEventArgs e)
{
myGrid.EditIndex = e.NewEditIndex;
Doldur();
}
private void Doldur2()
{
WebHelper.FillGridView(myGrid2, Service.GetProductsByCategories(??????));
}
protected void myGrid2_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = null;
if (e.CommandSource is ImageButton)
{
row = ((e.CommandSource as ImageButton).NamingContainer) as GridViewRow;
}
int id = 0;
int.TryParse(e.CommandArgument.ToString(), out id);
switch (e.CommandName)
{
case "sil2":
Service.Sil2(id);
break;
case "guncelle2":
// textbox'ı yakalamak için
TextBox txtKategoriAd2 = myGrid2.Rows[row.RowIndex].FindControl("txtKategoriAd2") as TextBox;
var product = new Products { ProductID = id, ProductName = txtKategoriAd2.Text };
Service.Update2(product);
// Edit moddan çıkılmalı..
myGrid2.EditIndex = -1;
break;
case "vazgec2":
myGrid2.EditIndex = -1;
break;
}
Doldur2();
}
protected void myGrid2_RowEditing(object sender, GridViewEditEventArgs e)
{
myGrid2.EditIndex = e.NewEditIndex;
Doldur2();
}
}