뭔가 이상한 일이 생겼습니다. 어쩌면 뭔가를 모르는 것입니까?GridView에서 컨트롤 찾기
(editItemTemplate의) 드롭 다운 목록을 채우려고 시도하는 중이고 그리드보기로드가 현재 포함 된 ID 대신 문자열로 채워지는 경우도 있습니다.
ASPX (이다와 내가 문제가있는 fiels &
<asp:GridView ID="gvAdminArticleAdd".....
<asp:TemplateField HeaderText="invsId" SortExpression="invsId">
<EditItemTemplate>
<asp:DropDownList ID="ddl_invNames" runat="server" AutoPostBack="True" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_insLabel" runat="server" Text='<%# Bind("invsId") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_invNamesNew" runat="server" AutoPostBack="True" />
</FooterTemplate>
</asp:TemplateField>
코드 숨김
protected void gvAdminArticleAdd_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//111111
//finding cotrols into the edit rows event
if (e.Row.RowState == DataControlRowState.Edit)
{
DropDownList ddlImages = (DropDownList)e.Row.FindControl("ddlImages");
ddlImages.DataSource = GetPdfs();
ddlImages.DataBind();
DropDownList ddlinvsNames = (DropDownList)e.Row.FindControl("ddl_invNames");
ArrayList invList = GetInvestigatorNames();
ddlinvsNames.DataSource = invList;
ddlinvsNames.DataBind();
}
//222222
//finding cotrols into rows
Label insLabel = (Label)e.Row.FindControl("lbl_insLabel");
int invsLabelId = int.Parse(insLabel.Text);
insLabel.Text = connection.GetInvsNameById(invsLabelId);
}
}
나는 RowDataBound 이벤트에서 발생하는이 문제, I 무엇이 잘못되었는지 알 수 없다.
// 111111 및 //22222가 올바르게 작동하지만 (내가 그 중 하나에 주석을 달았 으면) 함께 사용하지는 않습니다. 어떻게 그럴 수 있니?
내가 함께 내가
int invsLabelId = int.Parse(insLabel.Text);
개체 참조가 개체의 인스턴스로 설정되지 않았습니다 코드 줄에 오류가 점점 오전을 배치합니다. 오류가 이전 줄에 있지만 왜 그럴 수 없는지. 함께 하지만 (나는 그들 중 하나를 언급하는 경우)
고마워요 ... –