Hi,
I m using RadGrid and Calling usercontrol for Edit and Insert , my scenario is that when i have to display different icons on the each row of grid according to data So for this purpose i have taken one Item Template field in which i have called <asp:image /> and finding that control on Item Created so it bind the image with proper icon which i wanted but when i click on Edi button so it throws exception.
Please Kindly help me out how can i resolve this here's my code.
Please reply me asap its urgent, i will be very thankful
Regards,
Maham
I m using RadGrid and Calling usercontrol for Edit and Insert , my scenario is that when i have to display different icons on the each row of grid according to data So for this purpose i have taken one Item Template field in which i have called <asp:image /> and finding that control on Item Created so it bind the image with proper icon which i wanted but when i click on Edi button so it throws exception.
Please Kindly help me out how can i resolve this here's my code.
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
GridEditableItem eeditedItem = e.Item as GridEditableItem; |
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
if (!e.Item.OwnerTableView.IsItemInserted) |
{ |
ImageButton InsertButton = (userControl.FindControl("btnInsert") as ImageButton); |
InsertButton.Visible = false; |
if (ViewState["Complete"] == null) |
{ |
string[] comp = new string[] { }; |
Session["CompleteID"] = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"]); |
toDoList.ID = Convert.ToInt32(Session["CompleteID"]); |
comp = toDoList.SelectIsCompleted(); |
string a = comp[0]; |
string b = comp[1]; |
if (a == "True" || b == "true") |
{ |
TextBox Remarks = (userControl.FindControl("txtRemarks") as TextBox); |
Remarks.Enabled = false; |
TextBox task = (userControl.FindControl("txtTask") as TextBox); |
task.Enabled = false; |
RadDatePicker AssignDate = (userControl.FindControl("cmbAssignDate") as RadDatePicker); |
AssignDate.Enabled = false; |
DropDownList User = (userControl.FindControl("cmbUser") as DropDownList); |
User.Enabled = false; |
DropDownList task_cat = (userControl.FindControl("cmbCategory") as DropDownList); |
task_cat.Enabled = false; |
RadDatePicker TargetDate = (userControl.FindControl("cmbTargetDate") as RadDatePicker); |
TargetDate.Enabled = false; |
ImageButton updateButton = (userControl.FindControl("btnUpdate") as ImageButton); |
updateButton.Visible = false; |
ImageButton Complete = (userControl.FindControl("ImageButton4") as ImageButton); |
Complete.Visible = false; |
} |
ViewState["Complete"] = "Filled"; |
} |
else |
{ |
Session["CompleteID"] = null; |
ViewState["Complete"] = null; |
} |
} |
else |
{ |
ImageButton updateButton = (userControl.FindControl("btnUpdate") as ImageButton); |
updateButton.Visible = false; |
ImageButton Complete = (userControl.FindControl("ImageButton4") as ImageButton); |
Complete.Visible = false; |
ImageButton btnDelete = (userControl.FindControl("ImageButton1") as ImageButton); |
btnDelete.Visible = false; |
} |
} |
else |
{ |
if (e.Item is GridDataItem) |
{ |
string Status; |
Status = objResult.resultDS.Tables[0].Rows[e.Item.ItemIndex]["Status"].ToString(); |
if (Status == "Completed") |
{ |
Image flag = (Image)e.Item.FindControl("flag"); |
flag.ImageUrl = "Images/green.gif"; |
flag.ToolTip = "Complete"; |
} |
else if (Status == "Pending") |
{ |
Image flag = (Image)e.Item.FindControl("flag"); |
flag.ImageUrl = "Images/red.gif"; |
flag.ToolTip = "Pending"; |
} |
else |
{ |
Image flag = (Image)e.Item.FindControl("flag"); |
flag.ImageUrl = "Images/blue.gif"; |
flag.ToolTip = "Assigned"; |
} |
} |
} |
} |
Regards,
Maham