0
我在一個頁面上有兩個gridview ..我列出第一個比從commandargument(「id」)我列出的第二個..但我正在做這些gridviews我可以完成第一個gridview,因爲它沒有必要趕上id來列出它。它列出了它所有的。但第二個,我想列出該產品的類別。你可以幫我嗎 ?和單詞的翻譯;從gridview捕捉id到fillgridview
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();
}
}