I have the search form and RadGrid on the same page. I'm databinding the RadGrid using the button click in the codebehind. The search works, but when I click an Edit button in a row, the RadGrid disappears. If I click my search forms button again, the RadGrid reappears with the correct row in Edit Mode.
I think I'm missing data binding the RadGrid to an additional event handler, but I'm not sure. I've tried several events and it didn't change.
Here's my super-simplified code.
ASPX
<telerik:radscriptmanager runat="server"></telerik:radscriptmanager>
Column Name:
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="PROD_DIET_SUPP_NAME">Product Name</asp:ListItem>
<asp:ListItem Value="PRODUCT_CODE">Product Code</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
Function:
<asp:DropDownList ID="DropDownList4" runat="server">
<asp:ListItem Value="Contains">Contains</asp:ListItem>
<asp:ListItem Value="StartsWith">Starts With</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
Search Term:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1"
runat="server" Text="Search" onclick="Button1_Click" />
<telerik:RadGrid ID="RadGrid1" runat="server"
AllowSorting="True"
AllowAutomaticDeletes="True"
AllowAutomaticInserts="True"
AllowAutomaticUpdates="True"
EditMode="EditForms"
GridLines="None"
AutoGenerateColumns="False"
>
<MasterTableView
DataKeyNames="PRODUCT_CODE"
CommandItemDisplay="TopAndBottom">
<norecordstemplate>
No products have been entered matching your search crieteria. Try removing one of more keywords from your search and try again.
</norecordstemplate>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn"
ButtonType="imagebutton" />
<telerik:GridBoundColumn
DataField="PRODUCT_CODE"
DataType="System.Char"
HeaderText="Product Code"
ReadOnly="True"
SortExpression="PRODUCT_CODE"
UniqueName="PRODUCT_CODE" />
<telerik:GridBoundColumn EditFormColumnIndex="0"
DataField="PROD_DIET_SUPP_NAME" HeaderText="Name"
SortExpression="PROD_DIET_SUPP_NAME"
UniqueName="PROD_DIET_SUPP_NAME" />
</Columns>
<
EditFormSettings ColumnNumber="1" CaptionFormatString="Edit details for {0}" CaptionDataField="PROD_DIET_SUPP_NAME">
</
EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
CODEBEHIND
public
partial class search4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BindData()
{
DataClassesDataContext dc = new DataClassesDataContext();
string strWhere = "1=1";
string strKeyword = "";
string strColumn = "";
string strFunction = "";
strKeyword = TextBox1.Text;
strColumn = DropDownList1.SelectedValue;
strFunction = DropDownList4.SelectedValue;
string strOrderBy = "PROD_DIET_SUPP_NAME ASC";
if (!string.IsNullOrEmpty(TextBox1.Text))
{ strWhere = strColumn +
"." + strFunction + "(\"" + strKeyword + "\")"; }
var products = from m in (dc.PRODUCTs.Where(strWhere)
)
select new { m.PRODUCT_CODE, m.FORM_CODE, m.PROD_DOSAGE_CODE, m.PROD_DIET_SUPP_NAME, m.PROD_TYPE_CODE, m.SOURCE_PROD_CODE, m.PROD_PROD_INF_NOTES, m.PROD_IS_VERIFIED, m.PRODUCT_STATUS, m.LAST_VERIFIED_DATE, m.PROD_VERSION_CREATED, m.PROD_VERSION_NO, m.PROD_GENERIC_PROD, m.DATE_OF_RECIPT };
products = products.OrderBy(strOrderBy);
RadGrid1.DataSource = products;
RadGrid1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
BindData();
}
}