imagebutton 在 gridview datalist repeater 回傳或回調參數無效。

來源:互聯網
上載者:User

Hi Paula,

You can assign the ID for each row in the GridView via the sample code below. The code belows will give each row a unique ID from a global variable.

Dim intGRID as Integer = 1 'Global declaration

Protected Sub SampleGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles SampleGridView.RowDataBound

e.Row.ID = "sampleGridRow_" & Cstr(intGRID)
intGRID += 1 'Increase intGRID by one

End Sub

Hope this helps.

Hi all!

emptycan, thank you very much! Your solution is excellent!

If you don't want use additional variables, you can do this:

protected void SomeGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{

e.Row.ID = Guid.NewGuid().ToString();

}

Henk, not quite.  The Guid would be different for each postback, recreating the original problem.  Emptycan's solution works because his code will recreate the exact same IDs on each postback.

-Jason 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.