Reputation: 999
Is there a way to select a radgrid row from outside radgrid event for example like from inside a buttonclick event? I have a ragrid with a column "productname", some other columns and a GridClientSelectColumn(checkbox).
My page also has a textbox and a button. When user type a product name, say 'n', in textbox and press button, I want the checkbox of row containing that particular product name to get checked.
Is this possible? The reason why I want this in because, my users will scan the product name using barcode scanner.
Upvotes: 1
Views: 1415
Reputation: 11154
Please try with code snippet.
.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
{
// By using Datakey
if (item.GetDataKeyValue("ID").ToString() == "1")
{
item.Selected = true;
}
// By using column
if (item["Name"].Text== "Name1") // "Name" is column unique name
{
item.Selected = true;
}
}
}
.aspx
<MasterTableView DataKeyNames="ID">
<Columns>
<telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
</telerik:GridBoundColumn>
Upvotes: 1