Hi,
I have a radgrid in which i have placed the following controls
1)A RadTabstrip -with 2 pageviews (one for displaying a page and the another for displaying someother page)
2)someother page may not be visible based on the functionality most of the times. so i am checking for its visibility in itemcreated.
if visible false do not display the page 2
on clicking the expand collapse button it should expand /collapse the radgrid displaying the tabstrip.
3)added to this i have a validation in prerender event of the radgrid which has some validations as follows. means it reorders some columns and based on a condition makes few columns visible or not visible.
Here is the radgrid prerender event.
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
DataTable dtVerbatimColums = VerbatimGridSource;
int neworderindex = 4;
for (int i = 0; i < dtVerbatimColums.Rows.Count; i++)
{
if (dtVerbatimColums.Rows[i]["Label"].ToString() == "Default")
{
try
{
RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["ID"].ToString()).OrderIndex = neworderindex++;
}
catch (GridException)
{
continue;
}
}
else
{
try
{
RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["Label"].ToString()).OrderIndex = neworderindex++;
}
catch (GridException)
{
continue;
}
}
}
if (RadGrid1.MasterTableView.GetColumn("ActionNotes") != null)
{
RadGrid1.MasterTableView.GetColumn("ActionNotes").HeaderText = VS.VerbatimOptions.TextActionsWindow;
RadGrid1.MasterTableView.GetColumn("ActionNotes").Visible = VS.VerbatimOptions.ShowActionsWindow;
}
if (RadGrid1.MasterTableView.GetColumn("AppealStatus") != null)
{
RadGrid1.MasterTableView.GetColumn("AppealStatus").Visible = VS.VerbatimOptions.ShowAppeal;
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
RadGrid1.MasterTableView.GetColumn("Evaluate").Visible = VS.VerbatimOptions.ShowAppeal;
}
RadGrid1.Rebind();
foreach (GridDataItem item in RadGrid1.Items)
{
//Column Download
CheckBox cbAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
CheckBox cbHeadAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
if (cbAvailable != null)
{
cbAvailable.Checked = IsItemChecked(Convert.ToInt32(item["id"].Text));
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, cbAvailable);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, RadGrid1);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, cbHeadAvailable);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, RadGrid1);
}
string decodedText = "";
string encodedText = "";
// Check for empty transcription - if is it empty, remove all controls from cell and replace it with empty text, to avoid missing left and bottom cell border
if (RadGrid1.Columns.FindByUniqueName("Transcription").Visible)
{
GridTableCell cell = item["Transcription"] as GridTableCell;
Label textControl = cell.Controls[1] as Label;
if (string.IsNullOrEmpty(textControl.Text))
{
item["Transcription"].Controls.Clear();
item["Transcription"].Text = " ";
}
else
{
//added 28-Oct-2014
decodedText = Server.HtmlDecode(textControl.Text); //decode everything back first
encodedText = System.Security.SecurityElement.Escape(decodedText); //encode back only < > " ' & before outputting
//encodedText2 = Server.HtmlEncode(decodedText);
//item["Transcription"].Text = DescriptionTrunc(Server.HtmlEncode(decodedText)); //html encode output
//item["Transcription"].ToolTip = Server.HtmlEncode(decodedText); //html encode output
//added 28-Oct-2014
item["Transcription"].Text = DescriptionTrunc(encodedText);
item["Transcription"].ToolTip = encodedText;
}
}
if (!item["Type"].Text.Contains("V"))
{
item["Play"].Controls.Clear();
item["Play"].Text = " ";
}
else
{
string fileName = item["FileName"].Text;
ImageButton ib = item["Play"].Controls[1] as ImageButton;
if (ib == null) continue;
//Verbatim file check
if (fileName != string.Empty)
{
string path = VerbatimManager.GetVerbatimFilePath(fileName);
if (!File.Exists(path))
{
item["Play"].Controls.Clear();
item["Play"].Text = " ";
item["FileName"].Enabled = false;
continue;
}
}
//Permission check
if (!user.IsAuthorized(PermissionNames.Security_Verbatim_PlayVerbatim))
{
ib.Enabled = false;
continue;
}
//Play button tooltip
if (fileName != "")
{
ib.ToolTip = user.Translate("VerbatimResponses.Play") + " " + VerbatimManager.GetVerbatimFilePath(fileName);
ib.CommandArgument = fileName;
RadAjaxManager1.AjaxSettings.AddAjaxSetting(ib, ib);
}
if (!isPPTExport)
{
ib.Attributes.Add("OnMouseOver", "src='Images/play_over.gif';");
ib.Attributes.Add("OnMouseOut", "src='Images/play.gif';");
}
else
{
ib.Attributes.Add("src", "play.gif");
}
ib.AlternateText = user.Translate("VerbatimResponses.Play");
}
// 20141030
if (item["AppealStatus"].Text.Contains("Pending"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Navy;
}
else if (item["AppealStatus"].Text.Contains("Approved"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Green;
}
else if (item["AppealStatus"].Text.Contains("Declined"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Red;
}
}
}
Item Command Event of the radgrid.
//To make the tab page visible
RadPageView ExplorePageView;
RadPageView EvaluatePgView;
RadTabStrip rdtabexploreeval;
if (e.CommandName == "RowClick" || e.CommandName == "ExpandCollapse")
{
//if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)
//{
GridDataItem gridFormItem = e.Item as GridDataItem;
int VerbatimId = int.Parse(gridFormItem["id"].Text);
string sessionId = gridFormItem["SessionId"].Text;
string exploreurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Explore";
string evaluateurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Evaluate";
foreach (GridNestedViewItem item in radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");
ExplorePageView.ContentUrl = exploreurl;
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
rdtabexploreeval.Tabs[0].Text = user.Translate("VerbatimResponses.Explore");
rdtabexploreeval.Tabs[1].Text = user.Translate("verbatimResponses.evaluate");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
EvaluatePgView.ContentUrl = evaluateurl;
}
bool lastState = e.Item.Expanded;
if (e.CommandName == "ExpandCollapse")
{
lastState = !lastState;
}
CollapseAllRows();
e.Item.Expanded = !lastState;
}
if (e.CommandName.ToUpper() != "PLAY") return;
string fileName;
fileName = GetFileToDownload(e.CommandArgument.ToString());
// Added code by Raguraman on 12-DEC-2011 for VSMD-4612
if (!VS.VerbatimOptions.PlayVerbatimInNewBrowserPage)
{
SetDownloadButtons();
if (fileName != "")
{
verbatimManager.SetLastDownload(int.Parse(radgrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["id"].ToString()));
Misc.DownloadWavToResponse(fileName);
}
}
// END RadTabStrip rdtabexploreeval;
RadPageView EvaluatePgView;
//RadPageView ExplorePgView;
if (e.Item.Expanded == true)
{
e.Item.PreRender += new EventHandler(radgrid1_PreRender);
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
//switch off the evaluate tab strip visible false if showappeal is set to false.
if (VS.VerbatimOptions.ShowAppeal ==false)
{
foreach (GridNestedViewItem item in Radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
rdtabexploreeval.Tabs[1].Visible = false;
}
}
}
Item created event of the radgrid.
RadTabStrip rdtabexploreeval;
RadPageView EvaluatePgView;
//RadPageView ExplorePgView;
if (e.Item.Expanded == true)
{
e.Item.PreRender += new EventHandler(RadGrid1_PreRender);
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
//switch off the evaluate tab strip visible false if showappeal is set to false.
if (VS.VerbatimOptions.ShowAppeal ==false)
{
foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
rdtabexploreeval.Tabs[1].Visible = false;
}
}
}
The aspx page has this line of code onprerender="radgrid1_prerender"". my problem is i am not expand or collapse. more over i get this error "controls cannot be modified outside the collection"". please help.
-Thanks
Gayathri
I have a radgrid in which i have placed the following controls
1)A RadTabstrip -with 2 pageviews (one for displaying a page and the another for displaying someother page)
2)someother page may not be visible based on the functionality most of the times. so i am checking for its visibility in itemcreated.
if visible false do not display the page 2
on clicking the expand collapse button it should expand /collapse the radgrid displaying the tabstrip.
3)added to this i have a validation in prerender event of the radgrid which has some validations as follows. means it reorders some columns and based on a condition makes few columns visible or not visible.
Here is the radgrid prerender event.
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
DataTable dtVerbatimColums = VerbatimGridSource;
int neworderindex = 4;
for (int i = 0; i < dtVerbatimColums.Rows.Count; i++)
{
if (dtVerbatimColums.Rows[i]["Label"].ToString() == "Default")
{
try
{
RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["ID"].ToString()).OrderIndex = neworderindex++;
}
catch (GridException)
{
continue;
}
}
else
{
try
{
RadGrid1.Columns.FindByUniqueName(dtVerbatimColums.Rows[i]["Label"].ToString()).OrderIndex = neworderindex++;
}
catch (GridException)
{
continue;
}
}
}
if (RadGrid1.MasterTableView.GetColumn("ActionNotes") != null)
{
RadGrid1.MasterTableView.GetColumn("ActionNotes").HeaderText = VS.VerbatimOptions.TextActionsWindow;
RadGrid1.MasterTableView.GetColumn("ActionNotes").Visible = VS.VerbatimOptions.ShowActionsWindow;
}
if (RadGrid1.MasterTableView.GetColumn("AppealStatus") != null)
{
RadGrid1.MasterTableView.GetColumn("AppealStatus").Visible = VS.VerbatimOptions.ShowAppeal;
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
RadGrid1.MasterTableView.GetColumn("Evaluate").Visible = VS.VerbatimOptions.ShowAppeal;
}
RadGrid1.Rebind();
foreach (GridDataItem item in RadGrid1.Items)
{
//Column Download
CheckBox cbAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
CheckBox cbHeadAvailable = item["Download"].FindControl("chAvailable") as CheckBox;
if (cbAvailable != null)
{
cbAvailable.Checked = IsItemChecked(Convert.ToInt32(item["id"].Text));
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, cbAvailable);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbAvailable, RadGrid1);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, cbHeadAvailable);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(cbHeadAvailable, RadGrid1);
}
string decodedText = "";
string encodedText = "";
// Check for empty transcription - if is it empty, remove all controls from cell and replace it with empty text, to avoid missing left and bottom cell border
if (RadGrid1.Columns.FindByUniqueName("Transcription").Visible)
{
GridTableCell cell = item["Transcription"] as GridTableCell;
Label textControl = cell.Controls[1] as Label;
if (string.IsNullOrEmpty(textControl.Text))
{
item["Transcription"].Controls.Clear();
item["Transcription"].Text = " ";
}
else
{
//added 28-Oct-2014
decodedText = Server.HtmlDecode(textControl.Text); //decode everything back first
encodedText = System.Security.SecurityElement.Escape(decodedText); //encode back only < > " ' & before outputting
//encodedText2 = Server.HtmlEncode(decodedText);
//item["Transcription"].Text = DescriptionTrunc(Server.HtmlEncode(decodedText)); //html encode output
//item["Transcription"].ToolTip = Server.HtmlEncode(decodedText); //html encode output
//added 28-Oct-2014
item["Transcription"].Text = DescriptionTrunc(encodedText);
item["Transcription"].ToolTip = encodedText;
}
}
if (!item["Type"].Text.Contains("V"))
{
item["Play"].Controls.Clear();
item["Play"].Text = " ";
}
else
{
string fileName = item["FileName"].Text;
ImageButton ib = item["Play"].Controls[1] as ImageButton;
if (ib == null) continue;
//Verbatim file check
if (fileName != string.Empty)
{
string path = VerbatimManager.GetVerbatimFilePath(fileName);
if (!File.Exists(path))
{
item["Play"].Controls.Clear();
item["Play"].Text = " ";
item["FileName"].Enabled = false;
continue;
}
}
//Permission check
if (!user.IsAuthorized(PermissionNames.Security_Verbatim_PlayVerbatim))
{
ib.Enabled = false;
continue;
}
//Play button tooltip
if (fileName != "")
{
ib.ToolTip = user.Translate("VerbatimResponses.Play") + " " + VerbatimManager.GetVerbatimFilePath(fileName);
ib.CommandArgument = fileName;
RadAjaxManager1.AjaxSettings.AddAjaxSetting(ib, ib);
}
if (!isPPTExport)
{
ib.Attributes.Add("OnMouseOver", "src='Images/play_over.gif';");
ib.Attributes.Add("OnMouseOut", "src='Images/play.gif';");
}
else
{
ib.Attributes.Add("src", "play.gif");
}
ib.AlternateText = user.Translate("VerbatimResponses.Play");
}
// 20141030
if (item["AppealStatus"].Text.Contains("Pending"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Navy;
}
else if (item["AppealStatus"].Text.Contains("Approved"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Green;
}
else if (item["AppealStatus"].Text.Contains("Declined"))
{
item["AppealStatus"].ForeColor = System.Drawing.Color.Red;
}
}
}
Item Command Event of the radgrid.
//To make the tab page visible
RadPageView ExplorePageView;
RadPageView EvaluatePgView;
RadTabStrip rdtabexploreeval;
if (e.CommandName == "RowClick" || e.CommandName == "ExpandCollapse")
{
//if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)
//{
GridDataItem gridFormItem = e.Item as GridDataItem;
int VerbatimId = int.Parse(gridFormItem["id"].Text);
string sessionId = gridFormItem["SessionId"].Text;
string exploreurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Explore";
string evaluateurl = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Evaluate";
foreach (GridNestedViewItem item in radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");
ExplorePageView.ContentUrl = exploreurl;
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
rdtabexploreeval.Tabs[0].Text = user.Translate("VerbatimResponses.Explore");
rdtabexploreeval.Tabs[1].Text = user.Translate("verbatimResponses.evaluate");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
EvaluatePgView.ContentUrl = evaluateurl;
}
bool lastState = e.Item.Expanded;
if (e.CommandName == "ExpandCollapse")
{
lastState = !lastState;
}
CollapseAllRows();
e.Item.Expanded = !lastState;
}
if (e.CommandName.ToUpper() != "PLAY") return;
string fileName;
fileName = GetFileToDownload(e.CommandArgument.ToString());
// Added code by Raguraman on 12-DEC-2011 for VSMD-4612
if (!VS.VerbatimOptions.PlayVerbatimInNewBrowserPage)
{
SetDownloadButtons();
if (fileName != "")
{
verbatimManager.SetLastDownload(int.Parse(radgrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["id"].ToString()));
Misc.DownloadWavToResponse(fileName);
}
}
// END RadTabStrip rdtabexploreeval;
RadPageView EvaluatePgView;
//RadPageView ExplorePgView;
if (e.Item.Expanded == true)
{
e.Item.PreRender += new EventHandler(radgrid1_PreRender);
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
//switch off the evaluate tab strip visible false if showappeal is set to false.
if (VS.VerbatimOptions.ShowAppeal ==false)
{
foreach (GridNestedViewItem item in Radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
rdtabexploreeval.Tabs[1].Visible = false;
}
}
}
Item created event of the radgrid.
RadTabStrip rdtabexploreeval;
RadPageView EvaluatePgView;
//RadPageView ExplorePgView;
if (e.Item.Expanded == true)
{
e.Item.PreRender += new EventHandler(RadGrid1_PreRender);
}
if (RadGrid1.MasterTableView.GetColumn("Evaluate") != null)
{
//switch off the evaluate tab strip visible false if showappeal is set to false.
if (VS.VerbatimOptions.ShowAppeal ==false)
{
foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))
{
rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
rdtabexploreeval.Tabs[1].Visible = false;
}
}
}
The aspx page has this line of code onprerender="radgrid1_prerender"". my problem is i am not expand or collapse. more over i get this error "controls cannot be modified outside the collection"". please help.
-Thanks
Gayathri