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

I cannt figure out how to enable Edit,Add,Delete buttons

4 Answers 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stoyan
Top achievements
Rank 1
Stoyan asked on 10 Dec 2013, 12:24 PM

I want the grid to have Edit,Add,Delete button or selection but it wont let me ...

Here is the ascx



<%@ Control language="C#" Inherits="DotNetNuke.Modules.Maintenance_bitaddresses.View" AutoEventWireup="false" Codebehind="View.ascx.cs" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0"

DataSourceID="SqlDataSourceAddresses" GridLines="None"

AutoGenerateColumns="False" AllowAutomaticDeletes="True"

AllowAutomaticInserts="True" AllowAutomaticUpdates="True"

AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">

<mastertableview datasourceid="SqlDataSourceAddresses"

datakeynames="CryptoAddress,UserID">

<EditItemTemplate>

<telerik:RadTextBox ID="RadTextBox1" Runat="server" LabelWidth="64px"

Resize="None" Text='<%# Bind("CryptoAddress") %>' Width="160px">

</telerik:RadTextBox>

</EditItemTemplate>

<CommandItemSettings AddNewRecordText="Add" CancelChangesText="Cancel"

SaveChangesText="Save" ShowCancelChangesButton="True"

ShowExportToCsvButton="True" ShowSaveChangesButton="True" />

<Columns><telerik:GridBoundColumn DataField="CryptoAddress"

FilterControlAltText="Filter CryptoAddress column" HeaderText="Address"

ReadOnly="True" SortExpression="CryptoAddress" UniqueName="CryptoAddress"></telerik:GridBoundColumn><telerik:GridBoundColumn

DataField="AddressDescription"

FilterControlAltText="Filter AddressDescription column"

HeaderText="Description" SortExpression="AddressDescription"

UniqueName="AddressDescription"></telerik:GridBoundColumn><telerik:GridBoundColumn

DataField="UserID" DataType="System.Int32" Display="False"

FilterControlAltText="Filter UserID column" HeaderText="UserID" ReadOnly="True"

SortExpression="UserID" UniqueName="UserID"></telerik:GridBoundColumn></Columns></mastertableview>

</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSourceAddresses" runat="server"

ConnectionString="<%$ ConnectionStrings:bitratemeConnectionString %>"

SelectCommand="SELECT [CryptoAddress], [AddressDescription], [UserID] FROM [user_cryptoaddresses] WHERE ([UserID] = @UserID)"

ConflictDetection="CompareAllValues"

DeleteCommand="DELETE FROM [user_cryptoaddresses] WHERE [CryptoAddress] = @original_CryptoAddress AND [UserID] = @original_UserID AND (([AddressDescription] = @original_AddressDescription) OR ([AddressDescription] IS NULL AND @original_AddressDescription IS NULL))"

InsertCommand="INSERT INTO [user_cryptoaddresses] ([CryptoAddress], [AddressDescription], [UserID]) VALUES (@CryptoAddress, @AddressDescription, @UserID)"

OldValuesParameterFormatString="original_{0}"

UpdateCommand="UPDATE [user_cryptoaddresses] SET [AddressDescription] = @AddressDescription WHERE [CryptoAddress] = @original_CryptoAddress AND [UserID] = @original_UserID AND (([AddressDescription] = @original_AddressDescription) OR ([AddressDescription] IS NULL AND @original_AddressDescription IS NULL))">

<DeleteParameters>

<asp:Parameter Name="original_CryptoAddress" Type="String" />

<asp:Parameter Name="original_UserID" Type="Int32" />

<asp:Parameter Name="original_AddressDescription" Type="String" />

</DeleteParameters>

<InsertParameters>

<asp:Parameter Name="CryptoAddress" Type="String" />

<asp:Parameter Name="AddressDescription" Type="String" />

<asp:Parameter Name="UserID" Type="Int32" />

</InsertParameters>

<SelectParameters>

<asp:Parameter Name="UserID" Type="Int32" />

</SelectParameters>

<UpdateParameters>

<asp:Parameter Name="AddressDescription" Type="String" />

<asp:Parameter Name="original_CryptoAddress" Type="String" />

<asp:Parameter Name="original_UserID" Type="Int32" />

<asp:Parameter Name="original_AddressDescription" Type="String" />

</UpdateParameters>

</asp:SqlDataSource>

 


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2013, 12:39 PM
Hi Stoyan,

Your code works fine at my end. I see that you have set AutoGenerateDeleteColumn="True" and AutoGenerateEditColumn="True", setting these two properties in the Grid will give you Delete and Edit columns respectively. To show the Add New Record button, please set CommandItemDisplay property of the MasterTableView. Setting all this property to the RadGrid will give you Edit,Add,Delete for your Grid.
If this doesn't help,please provide your ASPX page code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True". . >
<MasterTableView CommandItemDisplay="Top">

Thanks,
Shinu


0
Stoyan
Top achievements
Rank 1
answered on 10 Dec 2013, 12:46 PM

great that worked but now I only get to enter the Descirption column and not the Address

I have removed the EditTemplate that I was trying to use but it still only gives me to enter Description and not Address field :(

0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2013, 01:01 PM
Hi Stoyan,

When you set ReadOnly="true" for a column, that will not be available for Edit/Insert. Hence please set ReadOnly="false" for the columns that you want to edit.

Thanks,
Shinu

0
Stoyan
Top achievements
Rank 1
answered on 10 Dec 2013, 01:32 PM

thanks

works perfect!



Tags
Grid
Asked by
Stoyan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Stoyan
Top achievements
Rank 1
Share this question
or