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

[Solved] Get Text from GridFilteringItem

1 Answer 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Hollen
Top achievements
Rank 1
Dave Hollen asked on 01 Mar 2010, 06:51 PM
Hello,

I am trying to get the text from each GridFilteringItem on the RadGrid that I am using.  I can get the filtering item, but the text value is always an empty string, even when I have something in the filter.

Here is the code:

protected

 

void rgContacts_OnItemCreated(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridFilteringItem)

 

{

 

GridFilteringItem filteringItem = e.Item as GridFilteringItem;

 

SetGridFilterItemWidth(filteringItem, rg_CONTACTS);

 


TextBox
contactName = (TextBox)filteringItem[CONTACT_NAME_COL].Controls[0];

 

 

if (contactName != null)

 

{

 

string contactNameFilter = contactName.Text;

 

 

if (!string.IsNullOrEmpty(contactNameFilter))

 

{

 

var query = from c in contactResultItem where System.Data.Linq.SqlClient.SqlMethods.Like(c.ContactName, "%" + contactNameFilter + "%") select c;

 

}

}

}

}

contactName.Text is always an empty string.

Suggestions?

Thanks,
Dave

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2010, 05:03 AM
Hello Dave,

Try your code in ItemDataBound event instead of ItemCreated, because the ItemCreated is fired before the item is data-bound and we cannot access the data in this event.
the help documentation describes this:
Distinguishing the major differences between ItemCreated and ItemDataBound events

Regards,
Shinu.
Tags
Grid
Asked by
Dave Hollen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or