3
asp.net 웹 양식 페이지에 리피터가 있습니다.리피터의 오브젝트 데이터에 액세스
repeater 데이터 소스는 "OrderLine"오브젝트의 목록입니다.
각 리피터 항목에는 주문 라인의 수량을 표시하는 TextBox 컨트롤이 있습니다.
텍스트 상자 컨트롤의 수량이 변경되면 OrderLine 개체의 전체 및 할인 값 속성을 다시 계산하는 자동 다시 게시가 있습니다.
내 질문은 리피터 항목의 색인을 가져 오는 대신 객체 데이터에 직접 액세스하여 아래의 개체 목록 색인을 가져 오는 대신에 더 좋은 방법이 있습니까?
가능한 경우 임시 변수를 만드는 대신 개체에 직접 액세스하고 싶습니다. 내가 알려 주시기 바랍니다 필요한 모든 정보를 누락 한 경우
protected void txtLineQuantity_TextChanged(object sender, EventArgs e)
{
RepeaterItem rItem = (RepeaterItem)((Control)sender).NamingContainer;
int i = rItem.ItemIndex;
decimal netPrice = OrderLines[i].NetPrice;
decimal netTotal = OrderLines[i].NetTotal;
int qty = OrderLines[i].Quantity;
decimal weight = OrderLines[i].Weight;
TextBox txtLineQuantity = (TextBox)rItem.FindControl("txtLineQuantity");
//... do calculations and bind data to repeater control
}
...
감사