This is a migrated thread and some comments may be shown as answers.

radgrid item .edit=true is problem

6 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shanker bangari
Top achievements
Rank 1
shanker bangari asked on 03 Mar 2010, 11:22 AM
Hi,

this is shanker am doing one project .My requirement is Radgridview one column is always in edit true It's ok fine ,It's working But when ever am change page index that  edit mode is false .how to keep edit is true always how to solve that 

This is my code 

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                 int? faciltyid = LogonDetails.Instance.sys_lclvar_default_facility_id;
                 Session["Facility_Id"] = faciltyid;
                 ExamName.DataSource = classmarksheetmanager.sch_view_exam_schedule_date(faciltyid);
                 ExamName.DataBind();
                 Class1.DataSource=studentremarks.sch_view_class_lookup(faciltyid);
                 Class1.DataBind();

                 for (int i = 0; i < mark_sheet.PageSize; i++)
                     {
                         mark_sheet.EditIndexes.Add(i);
                     }
                
            }
            
        }
        protected override int GetScreenId()
        {
            return Screens.classmarksheet;
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                foreach (Telerik.WebControls.GridDataItem item in mark_sheet.Items)
                {
                   
                        item.Edit = true;
                  
                  
                }
                
            }
        }
        

        protected void mark_sheet_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
        {
            if (e.CommandName == Telerik.WebControls.RadGrid.UpdateEditedCommandName)
            {
                XElement root=new XElement("mark_sheet");
                long IDNO = 1;
                for (int i = 0; mark_sheet.Items.Count > i; i++)
                {
                    int? class_student_id = int.Parse(mark_sheet.Items[i].OwnerTableView.DataKeyValues[i]["class_student_id"].ToString());
                    TextBox txtsocre = ((TextBox)mark_sheet.Items[i].Cells[5].Controls[0]) as TextBox;
                    if (txtsocre.Text != "")
                    {
                        XElement field = new XElement("csid", class_student_id);
                        XElement table = new XElement("id", IDNO);
                        XElement sorcexml = new XElement("score", txtsocre.Text);
                        table.Add(field);
                        root.Add(table);
                        (root.LastNode as XElement).Add(sorcexml);
                        IDNO++;
                        
                       
                    }
                }
                try
                {

                    string status_text = String.Empty;
                    bool res = classmarksheetmanager.sch_sproc_dml_sch_exam_result_upd(out status_text, root as XElement, Exam_Schedule_Date.SelectedValue.GetInteger());
                    if (res)
                    {
                        DisplayMessage(false, "Record updated");
                       Getdata();
                    }
                    else
                    {

                        DisplayMessage(true, "Can't update Record. Reason: " + status_text);
                    }
                }
                catch (Exception ex)
                {

                    DisplayMessage(true, "Record cannot be updated. Reason: " + ex.Message);
                }
            }
        }

        protected void Class1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            int? faciltyid = LogonDetails.Instance.sys_lclvar_default_facility_id;
            SubjectRadcom.DataSource = classmarksheetmanager.sch_view_class_subject_lookup(Class1.SelectedValue.GetInteger(), faciltyid);
            SubjectRadcom.DataBind();
        }

        protected void Exam_Schedule_Date_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Getdata();
        }

        protected void SubjectRadcom_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Exam_Schedule_Date.DataSource = classmarksheetmanager.sch_view_exam_start_date_lookup(ExamName.SelectedValue.GetInteger(), Class1.SelectedValue.GetInteger(), SubjectRadcom.SelectedValue.GetInteger());
            Exam_Schedule_Date.DataBind();
        }

        public void Getdata()
        {
            mark_sheet.DataSource = classmarksheetmanager.sch_view_exam_mark_list(Exam_Schedule_Date.SelectedValue.GetInteger());
            mark_sheet.DataBind();
        }

        protected void mark_sheet_PageIndexChanged(object source, Telerik.WebControls.GridPageChangedEventArgs e)
        {
                mark_sheet.CurrentPageIndex = e.NewPageIndex;
             
                Getdata();
               
        }
How to solve that please replay


thanks and regards
shanker.B

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2010, 06:28 AM
Hi Shanker,

Please  remove the IsPostback checking in the PreRender event of the grid. You also  need to rebind the grid in order for the grid to be in edit mode.

Thanks,
Princy
0
shanker bangari
Top achievements
Rank 1
answered on 04 Mar 2010, 10:01 AM
hi,

i remove ispostback in pre render than also i get same error .

thanks and regards

shanker.B
0
shanker bangari
Top achievements
Rank 1
answered on 09 Mar 2010, 10:43 AM
Hi,

thank you for your response i am remove is post back ,than again am face same problem .how to solve that please replay

thanks and regards 
shanker.b
0
shanker bangari
Top achievements
Rank 1
answered on 22 Mar 2010, 07:39 AM
Hi,

this is shanker am doing application my requirement is catch the databound value in Itemdatabound event in GridEditable mode I am write this code 

protected void fulldaygrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            int? student_absence_id = null;

            if ((e.Item is GridEditableItem || e.Item is GridDataItem) && e.Item.IsInEditMode)
            {



                GridEditableItem editedItem = (GridEditableItem)e.Item;
                int item = editedItem.ItemIndex - 1;
                    student_absence_id = editedItem.OwnerTableView.Items[item].Cells[1].ToString().GetInteger();
                    //int? eventId = GetEventId(e.Item);
                    if (student_absence_id.HasValue)
                    {
                        var det = studentattendancemanager.sch_view_student_absence_single_day_detail(student_absence_id);



                        //Label lblStudentname = e.Item.FindControl("lblStudentname") as Label;
                        //if (lblStudentname != null)
                        //{
                        //    string Name = det.first_name + det.last_name;
                        //    lblStudentname.Text = Name;
                        //}
                        //Label lblStudentNumber = e.Item.FindControl("lblStudentNumber") as Label;
                        //if (lblStudentNumber != null)
                        //{
                        //    lblStudentNumber.Text = det.student_number;
                        //}

                        TextBox txtDescription = e.Item.FindControl("txtDescription") as TextBox;
                        if (txtDescription != null)
                        {
                            txtDescription.Text = det.description;
                      }


                }   
            }
        }

it's not working i am face this error 
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

thanks and regards
shanker.B

0
shanker bangari
Top achievements
Rank 1
answered on 22 Mar 2010, 07:41 AM
Hi,

this is shanker am doing application my requirement is catch the databound value in Itemdatabound event in GridEditable mode I am write this code 

protected void fulldaygrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            int? student_absence_id = null;

            if ((e.Item is GridEditableItem || e.Item is GridDataItem) && e.Item.IsInEditMode)
            {



                GridEditableItem editedItem = (GridEditableItem)e.Item;
                int item = editedItem.ItemIndex - 1;
                    student_absence_id = editedItem.OwnerTableView.Items[item].Cells[1].ToString().GetInteger();
                    //int? eventId = GetEventId(e.Item);
                    if (student_absence_id.HasValue)
                    {
                        var det = studentattendancemanager.sch_view_student_absence_single_day_detail(student_absence_id);



                        //Label lblStudentname = e.Item.FindControl("lblStudentname") as Label;
                        //if (lblStudentname != null)
                        //{
                        //    string Name = det.first_name + det.last_name;
                        //    lblStudentname.Text = Name;
                        //}
                        //Label lblStudentNumber = e.Item.FindControl("lblStudentNumber") as Label;
                        //if (lblStudentNumber != null)
                        //{
                        //    lblStudentNumber.Text = det.student_number;
                        //}

                        TextBox txtDescription = e.Item.FindControl("txtDescription") as TextBox;
                        if (txtDescription != null)
                        {
                            txtDescription.Text = det.description;
                      }


                }   
            }
        }

it's not working i am face this error 
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

thanks and regards
shanker.B

0
shanker bangari
Top achievements
Rank 1
answered on 22 Mar 2010, 07:42 AM
Hi,

this is shanker am doing application my requirement is catch the databound value in Itemdatabound event in GridEditable mode I am write this code 

protected void fulldaygrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            int? student_absence_id = null;

            if ((e.Item is GridEditableItem || e.Item is GridDataItem) && e.Item.IsInEditMode)
            {



                GridEditableItem editedItem = (GridEditableItem)e.Item;
                int item = editedItem.ItemIndex - 1;
                    student_absence_id = editedItem.OwnerTableView.Items[item].Cells[1].ToString().GetInteger();
                    //int? eventId = GetEventId(e.Item);
                    if (student_absence_id.HasValue)
                    {
                        var det = studentattendancemanager.sch_view_student_absence_single_day_detail(student_absence_id);



                        //Label lblStudentname = e.Item.FindControl("lblStudentname") as Label;
                        //if (lblStudentname != null)
                        //{
                        //    string Name = det.first_name + det.last_name;
                        //    lblStudentname.Text = Name;
                        //}
                        //Label lblStudentNumber = e.Item.FindControl("lblStudentNumber") as Label;
                        //if (lblStudentNumber != null)
                        //{
                        //    lblStudentNumber.Text = det.student_number;
                        //}

                        TextBox txtDescription = e.Item.FindControl("txtDescription") as TextBox;
                        if (txtDescription != null)
                        {
                            txtDescription.Text = det.description;
                      }


                }   
            }
        }

it's not working i am face this error 
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

thanks and regards
shanker.B

Tags
Grid
Asked by
shanker bangari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
shanker bangari
Top achievements
Rank 1
Share this question
or