Hendrik Johns
Top achievements
Rank 1
Hendrik Johns
asked on 25 Aug 2010, 10:30 PM
Hi There,
I have a RadCombobox that is placed on a CommandItemTemplate and in my SqlDataSource Selecting event there I need to get the SelectedValue from the RadCombobox. I have tried to use the FindControl function but I can't get it to work so I would be happy if you could tell me how this is done :)
Thanks
Hendrik Johns
5 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 26 Aug 2010, 05:48 AM
Hello Hendrik,
Try the following code snippet to access the RadComboBox placed inside CommandItemTemplate.
C#:
Thanks,
Princy.
Try the following code snippet to access the RadComboBox placed inside CommandItemTemplate.
C#:
protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { GridCommandItem cmditem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; RadComboBox combo = (RadComboBox)cmditem.FindControl("RadComboBox2"); // Accessing RadComboBox inside CommandItemTemplate
}Thanks,
Princy.
0
Hendrik Johns
Top achievements
Rank 1
answered on 26 Aug 2010, 08:44 AM
Hi Princy,
Thanks that did the job :)
/Hendrik
Thanks that did the job :)
/Hendrik
0
Hendrik Johns
Top achievements
Rank 1
answered on 26 Aug 2010, 10:02 AM
My next problem is now that on the RadComboBox I have a AutoPostback event that shoud rebind the Grid. This also works fine except that the RadComboBox looses it selected value.
PS. I have tried to set the AllowCustomText to True, but as soon as I call the Rebind function it is gone
Cheers,
Hendrik Johns
PS. I have tried to set the AllowCustomText to True, but as soon as I call the Rebind function it is gone
Cheers,
Hendrik Johns
0
Princy
Top achievements
Rank 2
answered on 27 Aug 2010, 08:43 AM
Hello Hendrik,
One solution would be in that AutoPostBack event store the text of RadComboBox in a HiddenField. Then in PreRender event reset the text of RadComboBox by using that HiddenField value. Check out the following code snippet.
ASPX:
C#:
Thanks,
Princy.
One solution would be in that AutoPostBack event store the text of RadComboBox in a HiddenField. Then in PreRender event reset the text of RadComboBox by using that HiddenField value. Check out the following code snippet.
ASPX:
<asp:HiddenField ID="HiddenField1" runat="server" />C#:
protected void RadComboBox2_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox combo = (RadComboBox)o; HiddenField1.Value = combo.Text; this.RadGrid1.Rebind(); } protected void RadGrid1_PreRender(object sender, EventArgs e) { GridCommandItem cmdItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; RadComboBox combo = (RadComboBox)cmdItem.FindControl("RadComboBox2"); combo.Text = HiddenField1.Value; }Thanks,
Princy.
0
Shumaila Imran
Top achievements
Rank 1
answered on 01 Mar 2011, 06:00 PM
I've a Checkbox inside CommandItemTemplate and when I try to access the Checkbox in the ObjectDataSource Selecting event, I get the following error:
Could anyone please point out the reason of this error ?
Index was outside the bounds of the array
protected void ObjDataSourceTests_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { GridCommandItem cmditem = (GridCommandItem)RadGridTests.MasterTableView.GetItems(GridItemType.CommandItem)[0]; CheckBox chkTestsFilter = (CheckBox)cmditem.FindControl("chkTestsFilter"); e.InputParameters["getExpired"] = chkTestsFilter.Checked; }Could anyone please point out the reason of this error ?