I having a grid in which we create control dynamically in their header which will perfectly loaded below below on
ItemDataBound
method.
Method CreateHeaderControls(e); is doesn't call while we click a record on click which will call below method,
Is there any possibility to call CreateHeaderControls(e); in method RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
or else any alternate..thnx please help?
protected
override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
{
try
{
base.RaisePostBackEvent(source, eventArgument);
if (source == this.grdADInbox && eventArgument.IndexOf("RowDblClicked") != -1)
{
RadGrid rg = (RadGrid)source;
int index = int.Parse(eventArgument.Split(':')[1]);
========================================================================
protected
void grdADInbox_ItemDataBound(object sender, GridItemEventArgs e)
{
CreateHeaderControls(e);
}
private
void CreateHeaderControls(GridItemEventArgs args)
{
Button btnGroupApprove = new Button();
Button btnGroupReject = new Button();
String tranType = String.Empty;
Int32 tranCount = 0;
try
{
if (args.Item is GridGroupHeaderItem)
{
GridGroupHeaderItem item = args.Item as GridGroupHeaderItem;
DataRowView groupDataRow = (DataRowView)args.Item.DataItem;
if (groupDataRow != null)
{
tranType =
((System.Data.
DataRowView) (((Telerik.Web.UI.GridGroupHeaderItem) item).DataItem)).Row.ItemArray
.GetValue(0).ToString();
tranCount =
Convert.ToInt32(((System.Data.DataRowView)(((Telerik.Web.UI.GridGroupHeaderItem)item).DataItem)).Row.ItemArray
.GetValue(1).ToString());
}
btnGroupApprove.ID =
"btnGroupApprove";
btnGroupApprove.Text =
"Approve All";
btnGroupReject.ID =
"btnGroupReject";
btnGroupReject.Text =
"Reject All";
Label lbl = new Label();
lbl.ID =
"lblGroup";
String strGroupingText = item.DataCell.Text;
if (strGroupingText != " ")
{
if (strGroupingText.Contains("("))
{
strGroupingText = strGroupingText.Remove(strGroupingText.IndexOf(
"("));
}
lbl.Text = strGroupingText.Insert(strGroupingText.IndexOf(
"Total"), " ");
lbl.Text +=
" ";
item.DataCell.Controls.Add(lbl);
}
item.DataCell.Controls.Add(btnGroupApprove);
item.DataCell.Controls.Add(btnGroupReject);
}
string strApproveUrl = "ApproveAction.aspx?action=GroupApprove&&Tran_Type=" + tranType + "&&Tran_Count=" + tranCount;
string strRejectUrl = "ApproveAction.aspx?action=GroupReject&&Tran_Type=" + tranType + "&&Tran_Count=" + tranCount;
btnGroupApprove.Attributes.Add(
"onclick", "return ShowApprovalPopUp('" + strApproveUrl + "');");
btnGroupReject.Attributes.Add(
"onclick", "return ShowApprovalPopUp('" + strRejectUrl + "');");
}
catch (Exception ex)
{
throw ex;
}
}