This is a migrated thread and some comments may be shown as answers.
Grid disappear after postback from button search
1 Answer 11 Views
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 21 Jan 2016, 04:46 PM

hi

I am searching members through a textbox and then click a button Go. 

Before adding Dropdownlist in the grid, i was able to search for member and it display the result on the grid if found.

After adding a dropdownlist in the GridTemplateColumn, the grid disappear and display only dropdownlist.

 Have I done something wrong? Thanks a lot

 

<%@ Page Title="" Language="C#" MasterPageFile="~/crm/layout.master" AutoEventWireup="true" CodeFile="registration.aspx.cs" Inherits="registration" %>

<%@ Register src="../usercontrol/title.ascx" tagname="course" tagprefix="uc1" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Left" Runat="Server">
    <uc1:Title ID="Title1" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Middle" Runat="Server">
<div class="container">
         <h4>REGISTRATION</h4>
        <hr />
    <div>
       <div  class="col-xs-4">
            <div class="input-group">
                  <span class="input-group-btn" >
                      <asp:TextBox ID="txtSearch" runat="server" CssClass="form-control" placeholder="Search for..." />
                      <asp:Button ID="btnserach" cssclass="btn btn-default" runat="server" Text="Go" OnClick="btnserach_Click" />&nbsp;
                  </span>
            </div>
        </div> 
    </div> 
</div>
<div style="margin-left:5px;margin-top:15px;margin-right:5px">
<div>
    
        <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" Skin="Metro"  GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource">
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="MemberID" >
                <Columns>
                       <telerik:GridBoundColumn DataField="MemberID" FilterControlAltText="Filter MemberID column" HeaderText="Member ID" SortExpression="MemberID" UniqueName="MemberID">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Gender" Display="false" FilterControlAltText="Filter Gender column" HeaderText="Gender" SortExpression="Gender" UniqueName="Gender">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FullName" FilterControlAltText="Filter FullName column" HeaderText="Name" SortExpression="Salutation" UniqueName="FullName">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Email" FilterControlAltText="Filter Email column" HeaderText="Email" SortExpression="Email" UniqueName="Email">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DOB" DataType="System.DateTime" DataFormatString="{0:yyyy/MM/dd}"  FilterControlAltText="Filter DOB column" HeaderText="DOB" SortExpression="DOB" UniqueName="DOB">
                        <ColumnValidationSettings>
                            <ModelErrorMessage Text="" />
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn UniqueName="Uname" HeaderText="Title">
                        <ItemTemplate>
                            <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="CategoryIDDropDown" DataValueField="TitleID"
                                DataTextField="Title" DataSourceID="SqlDataSource1">
                            </telerik:RadDropDownList>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridButtonColumn CommandName="attendance" ConfirmText="Are you sure?" 
                        FilterControlAltText="Filter column column" HeaderText="Confirm Attendance" Text="Confirm Attendance" 
                        UniqueName="attendancecolumn" ItemStyle-ForeColor="#333333">
                        <ItemStyle ForeColor="#333333"></ItemStyle>
                    </telerik:GridButtonColumn>                
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

</div>
    <div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="Title_SelectDropdown" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
     </div>
</div>
</asp:Content>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class registration : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Session["mark"] = " ";
            RadGrid1.Rebind();
        }
    }
    protected void btnserach_Click(object sender, EventArgs e)
    {
        Session["mark"] = txtSearch.Text;
        RadGrid1.Rebind();
    }
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = Memberlib.Member_SelectMark(Session["mark"].ToString());
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 26 Jan 2016, 09:40 AM
Hello,

I examined the provided code and as far as I can see it looks correct. Could you please verify that you are not receiving any exception when you click the button? In case you are using AJAX I would recommend you to disable it and test the page again for exceptions. Additionally you can set a DataField to the TemplateColumn and see whether the issue remains.

Regards,
Kostadin
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
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or