2012-04-12 41 views
0

我有一個templatefield在templatefield中有一個文本框和filteredtextboxextender。我需要在c#代碼隱藏中將filteredtextboxextender的ValidChars屬性從「123」更改爲「abc」。 templatefield在GridView裏面。 我在aspx頁面中使用了下面的代碼。如何變更模板字段內控件的屬性?

<asp:GridView ID="grdEducation" runat="server" AllowSorting="True" AutoGenerateColumns="False" 
         AllowPaging="false" CellPadding="4" GridLines="Vertical" OnRowDeleting="grdEducation_RowDeleting" 
         OnRowDataBound="grdEducation_RowDataBound" OnRowUpdating="grdEducation_RowUpdating" ShowFooter="false" ShowHeader="true"> 
         <HeaderStyle CssClass="grid-header-style" /> 
         <Columns> 
         <asp:TemplateField HeaderStyle-CssClass="grid-label-small" >` 

    <ItemTemplate> 
            <table> 
             <tr> 
              <td width='90%'> 
               <table> 
               <td width='60%'> 
                 <asp:TextBox ID="textbox1" Width="100px" runat="server" 
                  ToolTip="Provide text" MaxLength="11"></asp:TextBox> 
                 <ajaxtoolkit:FilteredTextBoxExtender ID="filter" runat="server" TargetControlID="textbox1" 
                  ValidChars="123" /> 

                </td> 
               </table> 
    </td> 
             </tr> 
            </table> 
           </ItemTemplate> 
         </asp:TemplateField> 
         </Columns> 
</asp:GridView> 

有沒有可能改變像這樣的filteredtextboxextender屬性?

謝謝。

+0

哪些數據綁定控件? – Pankaj 2012-04-12 18:51:15

+0

請顯示你的.. gridview的代碼?和模板字段以及您要修改的文本框。還顯示任何你已經嘗試過的代碼。 – 2012-04-12 18:57:17

回答

0

註冊RowBoundData事件像下面。

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     YourControlType Conrol = (YourControlType)e.Row.FindControl("ControlID"); 
     //Set the property here 
    } 
} 

您同樣可以改變控件屬性在Row_Command事件也被用來

+0

@Kathirvel - 你從查詢中刪除了'GridView''標記'嗎? – Pankaj 2012-04-12 19:08:34

相關問題