Hello,
I had a scenario where I have to make a gridboundcolumn editable based on griddropdowncolumn selection. I am able to fire the selectindexchanged event for the griddropdowncolumn but could not figure how to change the readonly property of a column in the event.
Any help would be greatly appreciated.
Thanks,
Kevin
I had a scenario where I have to make a gridboundcolumn editable based on griddropdowncolumn selection. I am able to fire the selectindexchanged event for the griddropdowncolumn but could not figure how to change the readonly property of a column in the event.
Any help would be greatly appreciated.
Thanks,
Kevin
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 11 Jan 2010, 12:08 PM
Hello Kevin,
Try the following code snippet in order to set the ReadOnly property based on dropdown selection changed.
CS:
-Shinu.
Try the following code snippet in order to set the ReadOnly property based on dropdown selection changed.
CS:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem item = e.Item as GridEditableItem; |
RadComboBox combo = (RadComboBox)item["dropdowncolumnUniqueName"].Controls[0]; |
combo.AutoPostBack = true; |
combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged); |
} |
} |
void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
{ |
(RadGrid1.MasterTableView.GetColumn("BoundcolumnUniquName") as GridBoundColumn).ReadOnly = true; |
RadGrid1.MasterTableView.Rebind(); |
} |
-Shinu.
0
Kevin
Top achievements
Rank 1
answered on 11 Jan 2010, 03:15 PM
thanks for the reply shinu, it worked
thank you
--
Kevin
thank you
--
Kevin
0
Lucas
Top achievements
Rank 1
answered on 30 Jul 2014, 05:58 AM
Shinu,
Thanks for your post, this hasn't worked for me though. Running this thru debug it looks like it works, but yet the fields are still available within the edit screen when the page reloads.
Can you please let me know where I may be going wrong.
Code as below.
Thanks
Lucas
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
{
GridEditableItem edititem = (GridEditableItem)e.Item;
RadComboBox RadCombo = (RadComboBox)edititem["qt_factoryReq"].Controls[0];
RadCombo.AutoPostBack = true;
RadCombo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(RadCombo_SelectedIndexChanged);
}
}
void RadCombo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
RadComboBox radCombo = (RadComboBox)editedItem["qt_factoryReq"].Controls[0];
if (radCombo.SelectedValue == "Y")
{
(RadGrid1.MasterTableView.GetColumn("qt_factory") as GridBoundColumn).ReadOnly = true;
}
}
Thanks for your post, this hasn't worked for me though. Running this thru debug it looks like it works, but yet the fields are still available within the edit screen when the page reloads.
Can you please let me know where I may be going wrong.
Code as below.
Thanks
Lucas
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
{
GridEditableItem edititem = (GridEditableItem)e.Item;
RadComboBox RadCombo = (RadComboBox)edititem["qt_factoryReq"].Controls[0];
RadCombo.AutoPostBack = true;
RadCombo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(RadCombo_SelectedIndexChanged);
}
}
void RadCombo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
RadComboBox radCombo = (RadComboBox)editedItem["qt_factoryReq"].Controls[0];
if (radCombo.SelectedValue == "Y")
{
(RadGrid1.MasterTableView.GetColumn("qt_factory") as GridBoundColumn).ReadOnly = true;
}
}
0
Shinu
Top achievements
Rank 2
answered on 30 Jul 2014, 06:42 AM
Hi Lucas,
Please try rebinding the RadGrid as shown below.
C#:
Thanks,
Shinu.
Please try rebinding the RadGrid as shown below.
C#:
protected
void
RadCombo_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox selectComboBox=(RadComboBox)sender;
GridEditableItem editedItem = selectComboBox.NamingContainer
as
GridEditableItem;
if
(selectComboBox.SelectedValue ==
"Y"
)
{
(RadGrid1.MasterTableView.GetColumn(
"qt_factory"
)
as
GridBoundColumn).ReadOnly =
true
;
}
RadGrid1.MasterTableView.Rebind();
}
Thanks,
Shinu.
0
Lucas
Top achievements
Rank 1
answered on 30 Jul 2014, 08:09 AM
Shinu,
Sorry I should have included in the previous post that rebinding the page causes the fields to go back to their default values (i.e. blank). This also does not change the read only properties for the necessary fields on the grid.
Please let me know what else I can do.
thanks
Lucas
Sorry I should have included in the previous post that rebinding the page causes the fields to go back to their default values (i.e. blank). This also does not change the read only properties for the necessary fields on the grid.
Please let me know what else I can do.
thanks
Lucas
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2014, 05:21 AM
Hi Lucas,
One suggestion is to access the TextBox in edit mode and disable or hide it on SelectedIndexChanged event. Please try the following code snippet
C#:
Thanks,
Shinu.
One suggestion is to access the TextBox in edit mode and disable or hide it on SelectedIndexChanged event. Please try the following code snippet
C#:
protected
void
RadCombo_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox selectComboBox=(RadComboBox)sender;
GridEditableItem editedItem = selectComboBox.NamingContainer
as
GridEditableItem;
if
(selectComboBox.SelectedValue ==
"Y"
)
{
TextBox txtBox = (TextBox)editedItem[
"qt_factory"
].Controls[0];
txtBox.Visible =
false
;
// hide the textbox
txtBox.Parent.Parent.Visible =
false
;
//hide the header text
//OR
txtBox.Enabled =
false
;
//disable the textbox
}
}
Thanks,
Shinu.