0
데이터베이스의 데이터를 Gridview 콤보 박스 값에 바인딩하고 있습니다. 다음은 gridview 및 rowdatabound 이벤트의 코딩 부분입니다.bind dropdownlist return null 값
<asp:GridView ID="workingdaygrid" runat="server"
onrowdeleting="branchgrid_RowDeleting"
onrowediting="branchgrid_RowEditing"
onrowcancelingedit="branchgrid_RowCancelingEdit"
onrowupdating="branchgrid_RowUpdating" DataKeyNames="Workingday_id"
onpageindexchanged="workingdaygrid_PageIndexChanged" AllowPaging="True"
CellPadding="4" ForeColor="#333333" GridLines="None"
AutoGenerateColumns="False" onrowdatabound="workingdaygrid_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" CancelImageUrl="~/images/Cancel.jpg"
DeleteImageUrl="~/images/delete.jpg" EditImageUrl="~/images/Edit.jpg"
UpdateImageUrl="~/images/update.jpg" ButtonType="Image"/>
<asp:BoundField DataField="Workingday_id" HeaderText="WorkingDayID" />
<asp:BoundField DataField="Working_date" HeaderText="WorkingDayID" />
<asp:BoundField DataField="Working_day" HeaderText="WorkingDayID" />
<asp:TemplateField HeaderText="WorkingdayType">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Eval("Workingday_type") %>'></asp:Label></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="Workingdaytype" runat="server" Width="100px">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
및 행 바인딩 이벤트 코드 defugger (F11)를 이용하여 다음 행 DropDownList로 DL = (DropDownList로) e.Row 실행할 때 널 값을 반환 follwing을 맞춰
protected void workingdaygrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList dl = (DropDownList)e.Row.FindControl("Workingdaytype");
DataTable worktype = inter.bindworkdaytype();
dl.DataSource = worktype;
dl.DataTextField = "Workingday_type";
dl.DataValueField = "Time_id";
dl.DataBind();
}
}
이다. FindControl ("Workingdaytype");
이 게시물을 보았습니까? http://stackoverflow.com/questions/8573260/cant-find-dropdown-list-in-rowdatabound-event –
... 그리고 RowEditing() 대신 RowDataBound()를 사용하는 또 다른 예는 다음과 같습니다. http://stackoverflow.com/questions/833490/gridview-row-editing-dynamic-binding-a-dropdownlist –