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

Any one know that how to check command = edit or insert in Itemdatabound () event

2 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HHH
Top achievements
Rank 1
HHH asked on 15 Feb 2008, 07:56 PM
Hey,
I am doing inline edit in "Prometheus" RagGrid, 
I m trying to fill Dropdownlist at runtime when its been click for add new record,
I used ItemDataBound event but problem is that, it's been called when i do edit and also with insert
i kind of want only when its been clicked  "add new record"
Any one know that how to check command = edit or insert  in Itemdatabound () event




protected void RadGridSpecialty_ItemDataBound1(object sender, GridItemEventArgs e)

{

if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)

{

GridEditableItem editedItem = e.Item as GridEditableItem;

GridEditManager editMan = editedItem.EditManager;

GridDropDownColumnEditor editor = editMan.GetColumnEditor("ddlGridSepcialty") as GridDropDownColumnEditor;

//// My logic not related to Error

strSelect =

"select SpecialtyID, SpecialtyName from sl_Specialty where SpecialtyID NOT IN (1,3)";

 

DataSet dst = new DataSet();

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);

SqlCommand cnn = new SqlCommand(strSelect, con);

SqlDataAdapter adp = new SqlDataAdapter(cnn);

adp.Fill(dst);

editor.DataSource = dst.Tables[0];

editor.DataBind();

}

}

2 Answers, 1 is accepted

Sort by
0
Accepted
Goksun
Top achievements
Rank 1
answered on 15 Feb 2008, 08:40 PM
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)

        if (e.Item.OwnerTableView.IsItemInserted) 
        { 
            //item is about to be inserted 
        } 
        else 
        {
            //item is about to be edited  
         }
}

Hope this helps
Goksun
0
HHH
Top achievements
Rank 1
answered on 15 Feb 2008, 10:11 PM
Thanks Man,

Good

Thanks
Tags
Grid
Asked by
HHH
Top achievements
Rank 1
Answers by
Goksun
Top achievements
Rank 1
HHH
Top achievements
Rank 1
Share this question
or