2014-04-11 3 views
0

은 하나 하나 도움이 감사 controls.Any을 그리드 그룹화 통제 할에서 드롭 다운리스트를 채우기 syncfusion에 새로운 오전하는 방법을 도와 줄 수어떻게

+0

무엇을 시도 했습니까? –

답변

1

당신이 할 수있는 Rowdatabound를 사용하여 Syncfusion GridGroupingControl의 드롭 다운 목록을 채 웁니다.

은 ASPX 파일에 드롭 다운을 추가

[ASPX] Rowdatabound

를 사용

<Columns> 
……… 
<syncfusion:GridColumnDescriptor MappingName="Country" HeaderText="Country"> 
         <ItemTemplate> 
          <asp:DropDownList ID="ddlcountry" runat="server" Width="100px"/> 
         </ItemTemplate> 
</syncfusion:GridColumnDescriptor> 
……… 
</columns> 

[CS]는

protected void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e) 
     { 
      if (e.Element.Kind == DisplayElementKind.Record && e.Element.Kind != DisplayElementKind.AddNewRecord) 
      { 
       for (int i = 0; i < e.Row.Cells.Count; i++) 
       { 
        if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Country") 
        { 
         myConnection = new SqlCeConnection(ConnectionString); 
         myConnection.Open(); 
         DropDownList ddl = (DropDownList)e.Row.Cells[i].FindControl("ddlcountry");       
         SqlCeCommand cmd = new SqlCeCommand("SELECT Distinct Country FROM Employees", myConnection);       
         SqlCeDataAdapter da = new SqlCeDataAdapter(cmd); 
         DataSet ds = new DataSet();       
         da.Fill(ds);       
         myConnection.Close(); 
         ddl.DataSource = ds; 
         ddl.DataTextField = "Country"; 
         ddl.DataValueField = "Country"; 
         ddl.DataBind(); 
         ddl.Items.Insert(0, new ListItem("--Select--", "0")); 
        } 
       } 
      } 
     } 

우리가 알고 주시기 바랍니다 와이

+0

동일한 코드를 사용하고 있지만 조건이 처음 인 경우 입력하지 않습니다. 조건이 다음 조건에서 다시 시도하면 개체 참조가 개체 인스턴스로 설정되지 않았 음을 나타냅니다. – user2897388

0

첫 번째 조건은 레코드 행의 드롭 다운 목록 만 채우는 데 사용됩니다. 모든 레코드는 축소 된 상태이고 표 머리글 만 눈금에 표시되기 때문에 초기 그룹화시에는이 조건이 실행되지 않았습니다. 또한 그리드에 레코드가 없으면 실행되지 않습니다.

첫 번째 조건을 제거한 경우 열 머리글과 캡션 행에 대해 코드가 실행됩니다. 캡션 행에 ColumnDescriptor가 없으므로 "개체 참조가 개체 인스턴스로 설정되지 않았습니다"라는 문제의 원인입니다.