Hi,
I am using radGrid. My radGrid contain all posted "Questions" and Group by "Question Category".
I want to reorder questions and update it into database.
Reordering is working fine for same category BUT if i drop a row from one category to another, it wont work.
here, after dropping a row, how can i get destination "categoryID"....?????
(in grid itself, I want to move a question from one category to another category. )
plsss reply .....
Thanks
I am using radGrid. My radGrid contain all posted "Questions" and Group by "Question Category".
I want to reorder questions and update it into database.
Reordering is working fine for same category BUT if i drop a row from one category to another, it wont work.
here, after dropping a row, how can i get destination "categoryID"....?????
(in grid itself, I want to move a question from one category to another category. )
protected void rgQuestions_RowDrop(object sender, GridDragDropEventArgs e)
{
if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == rgQuestions.ClientID)
{
//reorder items in pending grid
IList<
Question
> questions = Questions;
Question order = GetQuestion(questions, (Int64)e.DestDataItem.GetDataKeyValue("Q_QuestionId"));
int destinationIndex = questions.IndexOf(order);
if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex)
{
destinationIndex -= 1;
}
if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex <
e.DraggedItems
[0].ItemIndex)
{
destinationIndex += 1;
}
List<Question> ordersToMove = new List<
Question
>();
foreach (GridDataItem draggedItem in e.DraggedItems)
{
Question tmpOrder = GetQuestion(questions, (Int64)draggedItem.GetDataKeyValue("Q_QuestionId"));
if (tmpOrder != null)
ordersToMove.Add(tmpOrder);
}
foreach (Question orderToMove in ordersToMove)
{
questions.Remove(orderToMove);
questions.Insert(destinationIndex, orderToMove);
}
Questions = questions;
rgQuestions.Rebind();
foreach (GridDataItem item in rgQuestions.MasterTableView.Items)
{
Question tmpOrder = GetQuestion(questions, (Int64)item.GetDataKeyValue("Q_QuestionId"));
string strQry = "Update Assess_QuestionMaster set Q_Order='"+ item.ItemIndex.ToString() +"' where Q_Questionid='" + tmpOrder.Q_QuestionId +"'";
MySQL.ExecuteSQL(strQry);
}
rgQuestions.Rebind();
int destinationItemIndex = destinationIndex - (rgQuestions.PageSize * rgQuestions.CurrentPageIndex);
e.DestinationTableView.Items[destinationItemIndex].Selected = true;
}
}
plsss reply .....
Thanks