簡體   English   中英

單擊Telerik radgrid中的“添加新記錄”時,如何訪問列中的文本框

[英]how do I access the textbox in a column when I click “Add new record” in the telerik radgrid

我有一個網格,單擊了“添加新記錄”按鈕,顯示了角色為:[TextBox]的文本框以及其下方的復選框和取消按鈕。 網格只有一個名為RoleName的列,標題為Role,如下所示。

替代文字
(來源: rjmueller.net

當我單擊復選框按鈕時,將觸發使用帶有三個參數(applicationId,applicationName,rolename)的objectdatasource的InsertCommand。 roleName必須是文本框的值。

我的網格稱為gvRoles。

我的objectdatasource稱為dsSecurity。

我可以使用幾行代碼來獲得此值嗎?

        protected void gvRoles_InsertCommand(object source, GridCommandEventArgs e)   
    {   
        //I need code here to retrieve the value of the textbox   

        dsSecurity.InsertMethod = "InsertRole";   

        String applicationId = cmbApplications.SelectedValue;   
        String applicationName = cmbApplications.SelectedItem.Text;   
        String roleName = "I need to set the role name from the textbox";   
        dsSecurity.InsertParameters["applicationId"].DefaultValue = applicationId;   
        dsSecurity.InsertParameters["applicationName"].DefaultValue = applicationName;   
        dsSecurity.InsertParameters["roleName"].DefaultValue = roleName;   

        gvRoles.DataBind();   
    }  

如果您具有自動生成的Telerik網格編輯表單,那么我將使用以下代碼來獲取所需的內容:

字符串roleName =((e.Item作為GridEditableItem)[“ Role”]。Controls [0]作為TextBox).Text;

如果您使用自定義編輯表單,請直接調用e.Item.FindControl(id)獲取對文本框的引用。

迪克

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM