[英]how to get the column index of the gridview
我在GridView中有兩個圖像按鈕用於選擇。 他們填充文本框。 我需要的是,當我單擊圖像按鈕“編輯”時,它應該從gridview中填充文本框,而當按下圖像按鈕“刪除”時,它也會執行同樣的操作,並且也討厭這些文本框。 關鍵不是要了解如何以編程方式獲取列索引的邏輯。 幫我解決這種情況。 問題只在於C#代碼。 這是我嘗試過的片段:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
var row = GridView1.SelectedRow;
if (condition)
{
_PropertyTitle.Text = row.Cells[1].Text;
_Address.Text = row.Cells[2].Text;
}
else
{
_PropertyTitle.Text = row.Cells[1].Text;
_PropertyTitle.Enabled = false;
_Address.Text = row.Cells[2].Text;
_Address.Enabled = false;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.