簡體   English   中英

在回發C#上觸發事件處理程序

[英]trigger an eventhandler on postback c#

我是C#編程的新手。 我遇到以下問題:我在Web窗體上具有GridView,DropDownList和Label控件。 當我從DDL中選擇一個值時,網格視圖中會填充數據庫中等於DDL條件的行(在我的情況下,DDL代表國家/地區,GV列出了城市)。 當我使用內置的GV刪除功能從GV刪除最后一個城市時,我想自動在標簽中寫明所選國家/地區中沒有其他城市。 我該如何實現? 我試圖把

protected void GridView1_RowDeleted1(object sender, GridViewDeletedEventArgs e)
{
    if (GridView1.Rows.Count == 0)
    {
        LabelGrid.Text = "No more cities.";
    }
}

但這沒用。

謝謝你的幫助

考慮使用PreRender事件,當該事件運行Row.Count屬性包含正確的值時。 (刪除后遞減)

    protected void GridView1_PreRender(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count == 0)
        {
            LabelGrid.Text = "No more cities.";
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM