2017-04-17 6 views
0

私はダイナミックコントロールでグリッドビューを持っています。リソース名はActive Directoryから取得したものです。検索フィルタは、姓、名、検索する検索のonlclickを入力する必要がある方法で機能します。複数のレコードがある場合は、modalpopupがドロップダウンリストに表示され、そこから選択するオプションが表示されます。グリッドビューの行のテキストボックスでモーダルポップアップ値を取得

enter image description here

enter image description here

問題は、私はGridViewの中に存在テキストボックスに取り込まドロップダウン値を取得することができませんということです。選択した行のテキストボックスにこのドロップダウン値が必要です。背後

コード:

protected void gvProjectResource_RowCommand(object sender, GridViewCommandEventArgs e) 
    { 
     if (e.CommandName == "Lookup") 
     { 
      GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow; 
      TextBox t2 = ((TextBox)clickedRow.FindControl("t2")); 

      DataTable dt = globalObj.FindPersons(t2.Text.Split(',')[0].Trim(), t2.Text.Split(',')[1].Trim()); 
      if (dt.Rows.Count > 1) 
      { 
       mpFindPerson.Show(); 
       ddlPersons.Items.Clear(); 
       ddlPersons.Items.Add(new ListItem { Value = "0", Text = "-Select User-" }); 
       ddlPersons.DataSource = dt; 
       dt.Columns.Add("FullName", typeof(string), "DisplayName + ' | ' + MSID"); 
       ddlPersons.DataTextField = "FullName"; 
       ddlPersons.DataValueField = "MSID"; 
       ddlPersons.DataBind(); 
      } 
      else 
      { 
       t2.Text = dt.Rows[0].ItemArray[0].ToString(); 
      } 
     } 
     if (e.CommandName == "Del") 
     { 

     } 
    } 

protected void btnSelectPerson_Click(object sender, EventArgs e) 
    { 
     TextBox t2 = (gvProjectResource.SelectedRow.FindControl("t2") as TextBox); 
     t2.Text = ddlPersons.SelectedItem.Text; 
     mpFindPerson.Hide(); 
    } 

ASPXコード:

<div id="four"> 
        <fieldset style="border: solid; border-width: thin; height: 220px; border-color: #a8a8a8;"> 
         <legend id="Legend11" runat="server" visible="true" style="width: auto; margin-bottom: 0px; font-size: 12px; font-weight: bold; color: #1f497d;">&nbsp;&nbsp; Project Resources &nbsp;&nbsp;</legend> 
         <div style="height: 210px; overflow: auto;"> 
          <asp:GridView ID="gvProjectResource" Width="88%" HeaderStyle-Font-Size="X-Small" CssClass="labels" runat="server" 
           ShowFooter="true" AutoGenerateColumns="false" Style="margin-right: auto; margin-left:7px;" 
           OnRowDataBound="gvProjectResource_RowDataBound" 
           OnRowCommand="gvProjectResource_RowCommand" > 
           <Columns> 
            <asp:TemplateField HeaderText="Role" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%"> 
             <ItemTemplate> 
              <asp:Label ID="lblRole" runat="server" Text='<%# Eval("role") %>' Visible="false" /> 
              <asp:DropDownList ID="ddlRole" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList> 
             </ItemTemplate> 
             <FooterTemplate> 
              <asp:DropDownList ID="ddlRole2" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList> 
             </FooterTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="Resource Name" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%"> 
             <ItemTemplate> 
              <asp:TextBox ID="t1" Height="23px" Width="98%" runat="server" ></asp:TextBox> 
             </ItemTemplate> 
             <FooterTemplate> 
              <asp:TextBox ID="t2" Height="23px" Width="68%" runat="server"></asp:TextBox> 
              <asp:LinkButton runat="server" Text="Lookup" CommandName="Lookup" /> 
             </FooterTemplate> 
            </asp:TemplateField> 
            <asp:TemplateField ItemStyle-VerticalAlign="Top" ItemStyle-Width="5%"> 
             <ItemTemplate> 
              <asp:LinkButton runat="server" Text="Delete" CommandName="Del" /> 
             </ItemTemplate> 
            </asp:TemplateField> 
           </Columns> 
          </asp:GridView> 
          <br /> 
          <div style="text-align: right;"> 
           <asp:LinkButton runat="server" Text="Add New" ID="LinkButton2" CssClass="labels"></asp:LinkButton> 
          </div> 
         </div> 

         <asp:Button runat="server" ID="btnModalPopUpSearch" Style="display: none" /> 
         <AjaxToolkit:ModalPopupExtender ID="mpFindPerson" 
          BehaviorID="mpFindPersonBehav" 
          runat="server" 
          DropShadow="true" 
          BackgroundCssClass="modalBackground" 
          PopupControlID="pnlFindPerson" 
          TargetControlID="btnModalPopUpSearch"> 
         </AjaxToolkit:ModalPopupExtender> 
         <asp:Panel runat="Server" ID="pnlFindPerson" CssClass="modalPopup" style="position:relative;"> 
          <div class="labels" runat="server" style="text-align:center; position:absolute; top:20%; height:10em; margin-top:auto; margin-left:20px;"> 
           <asp:DropDownList ID="ddlPersons" runat="server" AppendDataBoundItems="true" Width="200px"> 
            <asp:ListItem Text="-Select User-" Value="0" /> 
           </asp:DropDownList> 
           <br /> 
           <br /> 
           <br /> 
           <div style="text-align: center;"> 
            <asp:Button runat="server" Font-Size="9pt" Text="Select" CssClass="buttons___" Style="float: left;" 
             ID="btnSelectPerson" OnClick="btnSelectPerson_Click" /> 
           </div> 
          </div> 
         </asp:Panel> 

        </fieldset> 
       </div> 

答えて

0

OK、そう、行うにはあまり何もありませんでした。

これを追加する必要があります。

protected void btnSelectPerson_Click(object sender, EventArgs e) 
    { 
     TextBox t2 = (TextBox)gvProjectResource.FooterRow.FindControl("t2"); 
     t2.Text = ddlPersons.SelectedItem.Text; 

     mpFindPerson.Hide(); 
    } 
関連する問題