How to get the cell value by column name not by index in GridView in asp.net

后端 未结 10 1634
轻奢々
轻奢々 2020-12-01 06:21

I am having a gridview in asp.net and now I want the cell value by the column name but not by the cell index.

How would be it possible

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 06:28

    It is possible to use the data field name, if not the title so easily, which solved the problem for me. For ASP.NET & VB:

    e.g. For a string:

    Dim Encoding = e.Row.DataItem("Encoding").ToString().Trim()

    e.g. For an integer:

    Dim MsgParts = Convert.ToInt32(e.Row.DataItem("CalculatedMessageParts").ToString())

提交回复
热议问题