0

こんにちは、よろしくお願いします。

誰かが Gridview の現在の状態を取得して、後で何かを行うために使用できるようにする例を教えてくれるかどうか疑問に思っています。ViewState オブジェクトを使用することがこれに対する正しいアプローチであるかどうかはわかりません。もしそうなら、ViewState に保存して後で何かに使用する例が必要です。

動的LINQでasp.netとc#を使用しています

4

1 に答える 1

0

を使用して行から状態を取得できますDataControlRowState

MSDNから:

Member name Description
Alternate:  indicates that the data control row is an alternate row.
The Alternate state can be combined with other states, such as Normal, Edit, or Insert, at any time. These rows might be affected by the AlternateRowStyle property of the data control, if set.
Edit:   indicates that the row is in an edit state, often the result of clicking an edit button for the row. Typically, the Edit and Insert states are mutually exclusive.
Insert: indicates that the row is a new row, often the result of clicking an insert button to add a new row. Typically, the Insert and Edit states are mutually exclusive.
Normal: indicates that the data control row is in a normal state. The Normal state is mutually exclusive with other states except the Alternate state.
Selected:   indicates that the row has been selected by the user.

例えば:

protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
  if (rowState & DataControlRowState.Edit) != 0)
  {
     /*Do Stuff that you need here*/
  }
}
于 2013-07-24T21:05:06.227 に答える