Hello,
The RadGrid filtering doesn't work. The RadGrid is empty shows empty when I filter by last name. Could you please let me know what could be the problem? Thanks for any help. Her is my code.
Code behind
The RadGrid filtering doesn't work. The RadGrid is empty shows empty when I filter by last name. Could you please let me know what could be the problem? Thanks for any help. Her is my code.
<
telerik:RadGrid
ID
=
"RadGrid1"
AutoGenerateColumns
=
"False"
AlternatingItemStyle-HorizontalAlign
=
"Left"
FilterItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Center"
ItemStyle-HorizontalAlign
=
"Left"
Width
=
"101%"
runat
=
"server"
AllowPaging
=
"True"
GridLines
=
"None"
AllowFilteringByColumn
=
"true"
ShowFooter
=
"True"
ShowStatusBar
=
"True"
OnItemCommand
=
"Add"
AllowSorting
=
"true"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
></
HeaderContextMenu
>
<
AlternatingItemStyle
BackColor
=
"gainsboro"
/>
<
MasterTableView
PageSize
=
"50"
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
></
PagerStyle
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"test_id"
UniqueName
=
"test_id"
HeaderText
=
"Test ID"
Display
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"last_name"
UniqueName
=
"last_name"
FilterControlAltText
=
"Filter last_name column"
HeaderText
=
"Name"
SortExpression
=
"last_name"
/>
<
telerik:GridButtonColumn
CommandName
=
"TestSelected"
FilterControlAltText
=
"Filter column column"
Text
=
"Add"
UniqueName
=
"column"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
FilterMenu
EnableTheming
=
"True"
Skin
=
"Default"
>
<
CollapseAnimation
Duration
=
"200"
Type
=
"OutQuint"
/>
</
FilterMenu
>
<
AlternatingItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
FilterItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:RadGrid
>
Code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (this.Request.QueryString["name"] != string.Empty)
{
string sqlstr = "SELECT * from tableName where last_name = '" + this.Request.QueryString["name"] + "') ";
RadGrid1.DataSource = GetDataTable(sqlstr);
RadGrid1.DataBind();
RadGrid1.Visible = true;
}
}
else
{
RadGrid1.DataSource = null;
RadGrid1.Rebind();
RadGrid1.Visible = true;
}
}
}