Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Telerik RadGrid中找不到控件_C#_Telerik_Telerik Grid - Fatal编程技术网

C# 在Telerik RadGrid中找不到控件

C# 在Telerik RadGrid中找不到控件,c#,telerik,telerik-grid,C#,Telerik,Telerik Grid,我试图找到一个控件,它位于Telerik RadGrid编辑表单中。我需要能够在页面加载中做到这一点,但是我看到的大多数示例都是关于itemDataBound的,但是我需要能够在页面加载中设置一个值,并在单击按钮时保存一个值 <telerik:RadGrid ID="rgNotes" runat="server" GroupPanelPosition="Top"> <GroupingSettings CollapseAllTooltip="Collapse all gr

我试图找到一个控件,它位于Telerik RadGrid编辑表单中。我需要能够在页面加载中做到这一点,但是我看到的大多数示例都是关于itemDataBound的,但是我需要能够在页面加载中设置一个值,并在单击按钮时保存一个值

<telerik:RadGrid ID="rgNotes" runat="server" GroupPanelPosition="Top">
    <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
    <MasterTableView NoDetailRecordsText="No notes for this Appointment" AutoGenerateColumns="False" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Notes" AllowAutomaticInserts="true" EditMode="PopUp">
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="Subject" FilterControlAltText="Filter Subject column" HeaderText="subject" ReadOnly="True" SortExpression="Subject" UniqueName="Subject">
            </telerik:GridBoundColumn>
        </Columns>

        <EditFormSettings EditFormType="Template" InsertCaption="Add new Note">
            <FormTemplate>
                Subject
                <p>
                    <telerik:RadTextBox ID="txtSubjectNotes" Width="200px" runat="server"></telerik:RadTextBox>
                </p>
                <p>
                </p>

                <telerik:RadButton ID="rdSaveNotes" OnClick="rdSaveNotes_Click" Skin="Bootstrap" BackColor="#512479" ForeColor="White" runat="server" Text="Save Notes"></telerik:RadButton>
                <telerik:RadButton ID="rdCancel" OnClick="rdCancel_Click1" CommandName="Cancel" Skin="Bootstrap" BackColor="#512479" ForeColor="White" runat="server" Text="Cancel"></telerik:RadButton>
            </FormTemplate>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnPopUpShowing="PopUpShowing" />
        <Selecting AllowRowSelect="true" />
    </ClientSettings>
</telerik:RadGrid>

这是因为当控件放置在网格中时,它们不会在设计器文件中声明为页面控件

你必须以不同的方式掌握它们。在单击save按钮的情况下,您应该能够获得与按钮相关的文本框

尝试:

protected void rdSaveNotes_Click(object sender, EventArgs e)
{
    try
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);
        tblApertureNetNote _note = new tblApertureNetNote();
        _note.appointment_id = id;

        _note.isActive = true;
        _note.isDeleted = false;
        _note.subject = txtSubjectNotes.Text; //It's here i can't find the textbox

        _dal.Addnotes(_note);
        rgNotes.DataBind();
    }
    catch (Exception ex)
    {
        logger.Error("Error in rdSaveNotes_Click function calandar edit.aspx" + ex.ToString());
    }
}
var button = (Control)sender;  // sender is the button

// then ask the button's parent control to find the textbox
var txtSubjectNotes = button.Parent.FindControl("txtSubjectNotes") as RadTextBox; 

if(txtSubjectNotes != null) 
{
    // make sure it's not null
    _note.subject = txtSubjectNotes.Text;
}