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

Access Value in CommandItemTemplate During NeedDataSource

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TallOne
Top achievements
Rank 2
TallOne asked on 28 May 2015, 04:51 PM

Hello All,

 I'm having problems accessing a value in the OnNeedDataSource event.  The value is a textbox in the CommandItemTemplate.  I'm using it as a custom filter while building the datasource.  I've done this before but forgot how I did it. :(  It seems that during the OnNeedDataSource the CommandItemTemplate has not been created yet. 

 

Thanks,
Jerry

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 29 May 2015, 10:37 AM
Hi,

You can access textbox control placed in CommandItemTemplate on ItemCreated or PreRender server-side events of the grid. Try using the code snippet below and let me know about the result:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
  {
      if (e.Item.ItemType == GridItemType.CommandItem)
      {
          var textBox = (TextBox)e.Item.FindControl("TextBox1");
          // Your logic here
      }
  }

Additionally, I recommend you check out the article below which elaborates on accessing controls in RadGrid:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

Regards,
Pavlina
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
TallOne
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or