This is a migrated thread and some comments may be shown as answers.

RadGrid "Add" button is not working at all. Nothing happens on Add button click.

1 Answer 231 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Priyanka
Top achievements
Rank 1
Priyanka asked on 12 Jun 2015, 01:39 AM

Hi,

I have a RadGrid on my web page in which I am implementing only "Add records" functionality.
When I try to click on "Add" button, nothing happens (it do not show panel to add records in it)

Please reply what mistake I am doing in my code.

Below is the .aspx (say "Default.aspx" page) code:

<telerik:RadMultiPage ID="RadMultiPage4" runat="server" SelectedIndex="0" Width="100%">
                                                                            <telerik:RadPageView ID="RadPageView3" runat="server" Width="100%">
                                                                                <telerik:RadAjaxPanel ID="RadAjaxPanel3" runat="server">
                                                                                            
                                                                                     <asp:label ID="Label2" runat="server" style="display: none;"/>
                                                                               
          <telerik:RadGrid ID="RGGSTChat" runat="server"  AutoGenerateColumns="false"
              ShowStatusBar="true" EnableEmbeddedSkins="true" Skin="Outlook"
              OnNeedDataSource= "rggstChat_NeedDataSource" OnInsertCommand="RGGSTChat_InsertCommand">
 
          <mastertableview commanditemdisplay="Top" autogeneratecolumns="false" datakeynames="ChatID"
            insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True">
                    <CommandItemSettings AddNewRecordText="New" />
                                    <Columns>
                                         
                                        <telerik:GridBoundColumn DataField="ChatID" HeaderText="Id"
                                            UniqueName="ChatID" SortExpression="ChatID" Visible="false">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatTo" HeaderText="To"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatCc" HeaderText="Cc"
                                            UniqueName="ChatTo" SortExpression="ChatTo">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
                                         
                                        <telerik:GridBoundColumn DataField="ChatSubject" HeaderText="Subject"
                                            UniqueName="ChatSubject" SortExpression="ChatSubject">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>
 
                                        <telerik:GridBoundColumn DataField="ChatContent" HeaderText="Content"
                                            UniqueName="ChatContent" SortExpression="ChatContent">
                                            <ItemStyle HorizontalAlign="Right" />
                                            <FooterStyle HorizontalAlign="Right" />
                                        </telerik:GridBoundColumn>                                     
                                         
                                    </Columns>
                                    <EditFormSettings>
                                        <EditColumn ButtonType="ImageButton" />
                                    </EditFormSettings>
                                    <PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" />
                   </mastertableview>
            </telerik:RadGrid>
 
 
                                                                                </telerik:RadAjaxPanel>
                                                                            </telerik:RadPageView>
                                                                        </telerik:RadMultiPage>

C# code:

protected void rggstChat_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        Label GUID = fvIPRForm.FindControl("TempGUID") as Label; // RequestID
        RadGrid RGGSTChat = fvIPRForm.FindControl("RGGSTChat") as RadGrid;
        if (!string.IsNullOrEmpty(Request.QueryString["RequestID"]))
        {
            GUID.Text = Request.QueryString["RequestID"];
        }
 
        if (string.IsNullOrEmpty(GUID.Text))
        {
            GUID.Text = Session["GUID"].ToString();
        }
 
        DataTable dt = IPRRequest.SelectChatData(new Guid(GUID.Text));
        RGGSTChat.DataSource = dt;
 
        Response.Write("Page_Load Error. Reason: " + GUID.Text);
    }

protected void RGGSTChat_InsertCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem item = e.Item as GridEditableItem;
 
        Label requestID = fvIPRForm.FindControl("TempGUID") as Label;
 
        string chat_to = (item["lblTo"].Controls[1] as Label).Text;
        string chat_cc = (item["lblCc"].Controls[2] as Label).Text;
        string chat_subj = (item["lblSubject"].Controls[3] as Label).Text;
        string chat_Content = (item["lblContent"].Controls[4] as Label).Text;
        string loginUser = AD_Guard.Checker(Session["LoginUser"].ToString()) + "";
 
        IPRRequest.InsertChatData(new Guid(requestID.Text), chat_to, chat_cc, chat_subj, chat_Content, loginUser);  
    }

This is the .dll (say "abc.cs" page) code, this .dll is used for DB connection:

public static DataTable SelectChatData(Guid requestID)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestId", requestID}
                //{"@ChatID", null},
                //{"@ChatTo", chatTo},
                //{"@ChatCc", chatCC},
                //{"@ChatSubject", chatSubj},
                //{"@ChatContent", chatMsg}
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "Invoice.usp_tbl_Request_Chat_Select", input);           
            return dt;
        }
    
        public static DataTable InsertChatData(Guid requestID, string chat_to, string chat_cc, string chat_subj,
            string chat_Content, string loginUser)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@RequestID", requestID},
                {"@ChatTo", chat_to},
                {"@ChatCc", chat_cc},
                {"@ChatSubject", chat_subj},
                {"@ChatContent", chat_Content},
                {"@CreatedBy", loginUser},
                {"@CreatedDate", DateTime.Now.ToString()}
                 
            };
            DataTable dt = data.ExecuteQuery(CommandType.StoredProcedure, "[Invoice].[usp_tbl_Request_Chat_Insert]", input);
            return dt;
        }

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 16 Jun 2015, 10:58 AM
Hello Priyanka,

The problem that you are facing is due to the fact that you are calling Response.Write method within an AJAX request, which is not supported scenario and if you inspect your browser's console you will notice that an exception will be thrown when you click on the "Add" button.

In order to handle this you will either have to disable AJAX or remove the line where you are calling the Response.Write method.

Detailed information on this matter could be found in the following article:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Priyanka
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or