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

problem in deleting

5 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 14 Sep 2011, 02:31 PM
i have added all columns at runtime. as well delete and edit as gridbutton columns..i m able to open a file on clicking delete but not able
 to delete..
following is the code
  gbtc = new GridButtonColumn();
            gbtc.HeaderText = "Delete";
            gbtc.UniqueName = "ibtnDelete";
            gbtc.ImageUrl = "~/App_Themes/Bari_Default/images/delete_ico.png";
            gbtc.ButtonType = GridButtonColumnType.ImageButton;
            gbtc.CommandName = "Delete";
            gbtc.Visible = false;
            gbtc.FilterImageToolTip = "";
            rgdProcedureMaster.MasterTableView.Columns.Add(gbtc);


do i need to add more information for it to get done

5 Answers, 1 is accepted

Sort by
0
Wojciech
Top achievements
Rank 1
answered on 14 Sep 2011, 02:54 PM
Check if you have  AllowAutomaticDeletes="true" in mastertableview, and your delete command in sqldatasource is valid.
0
Priya
Top achievements
Rank 1
answered on 15 Sep 2011, 07:01 AM
my problem is that on clicking delete command button,control is not getting passed to grid_ItemCommand event,due to which records are not getting deleted. and grid disappears
0
Shinu
Top achievements
Rank 2
answered on 15 Sep 2011, 07:42 AM
Hello Priya,

I am not sure in which event you have created the columns. When creating RadGrid on Page_Load event, the columns or detail tables should be added to the corresponding collection first and then values for the properties of this instance should be set. Remember to check the condition (Not IsPostBack) to avoid adding the same structure objects to the grid twice. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.

When generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set. No ViewState is required for grid structure to be persisted as it is recreated on each page initialization:

Thanks,
Shinu.
0
Priya
Top achievements
Rank 1
answered on 15 Sep 2011, 08:04 AM

 

 

following code is the part of my application
front end:

<
telerik:RadGrid ID="rgdProcedureMaster" runat="server" AllowPaging="True" GridLines
="Vertical"

AutoGenerateColumns="False" EnableEmbeddedSkins="False" Skin="BariRC" AllowSorting="True"

 AllowFilteringByColumn="True" PageSize="5" OnItemDataBound="rgdProcedureMaster_ItemDataBound"

CellSpacing="0" OnItemCommand="rgdProcedureMaster_ItemCommand" EnableViewState="true" DataSourcePersistenceMode="NoPersistence">

<GroupingSettings CaseSensitive="false" />

<SortingSettings EnableSkinSortStyles="false" />

 <ClientSettings>

<ClientEvents OnFilterMenuShowing="FilterMenuShowing" />

</ClientSettings>

<MasterTableView DataKeyNames="Id" AllowNaturalSort="false" EnableColumnsViewState="false">

</MasterTableView>

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_BariRC" EnableEmbeddedSkins="False">

</HeaderContextMenu>

</telerik:RadGrid>

 


code behind:

 

 private void loadColumn(IList<BOL.Master.LookupReference> iList, string lookUpType)

 

{

gbtc = new GridButtonColumn();

 gbtc.HeaderText = "Delete";

 gbtc.UniqueName = "ibtnDelete";

 gbtc.ImageUrl = "~/App_Themes/Bari_Default/images/delete_ico.png";

 gbtc.ButtonType = GridButtonColumnType.ImageButton;

 gbtc.CommandName = "Delete";

 gbtc.Visible = false;

 gbtc.ConfirmDialogType = GridConfirmDialogType.RadWindow;

 gbtc.FilterImageToolTip = "";

 rgdProcedureMaster.MasterTableView.Columns.Add(gbtc);

}

  

protected void rgdProcedureMaster_ItemCommand(object sender, GridCommandEventArgs e)

 {

 

if (e.CommandName == "Page" || e.CommandName == "ChangePageSize" || e.CommandName == "Sort" || e.CommandName == "Filter")

{

LoadGridColumns();

ConfigForm();

LoadProcedureData();

}

else if (e.CommandName == "Delete")

 

{

GridDataItem item = (GridDataItem)e.Item;

string procedureIds = Convert.ToString(item.GetDataKeyValue("Id")) + ",";

Result result = BariAnalyticsEHR.BLL.Master.Management.Procedures.DeleteProcedures(procedureIds, BOL.Classes.EHRSessions.ClinicId, BOL.Classes.EHRSessions.UserId, LanguageCulture.EN_US);

if (result.Status)

{

loadColumn();

}}}

and i m calling this loadColumn() method in Bind() of the widget since i m using Dashboard.
i m able to load another page on clicking edit image button but when i click on delete image button,the grid disappears and i when i change page size of the grid the ItemCommand event is getting fired but its not getting fired for paging,sortong and for delete..

 

 

0
Shinu
Top achievements
Rank 2
answered on 21 Sep 2011, 10:56 AM
Hello Priya,

 I guess you are populating RadGrid in PageLoad event. Bind your grid using advanced Data-binding(Using NeedDataSource event).

Please refer the following documentation
Advanced Data-binding (using NeedDataSource event)

-Shinu.
Tags
Grid
Asked by
Priya
Top achievements
Rank 1
Answers by
Wojciech
Top achievements
Rank 1
Priya
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or