ASP.NET GRIDVIEW- 데이터가 바인딩되기 전에 데이터 소스에 액세스하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/802645

  •  03-07-2019
  •  | 
  •  

문제

그리드에 바인딩하기 전에 DataSource에 액세스하려고합니다. 어떻게해야하나요? 내 생각에 나는 Grid.databinding과 같은 이벤트 중 하나를 살펴 봐야합니다.

도움이 되었습니까?

해결책

Yes, the GridView.DataBinding event will be raised prior to the control being bound. You can access the DataSource control in that event and make modifications if you so desire (for example, modifying parameters).

protected void Grid_DataBinding(object sender, EventArgs e)
{
  mySqlDataSource.SelectCommand = "Select * from Stars";
}

다른 팁

One way would be to not define the datasource on the grid itself. In the page_load, create and populate your datasource and then dynamically bind it to your datagrid. That way you would be able to access it.

Hope it helps!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top