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

How to enable Automatic properties of RadGrid

3 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 15 Oct 2010, 05:29 AM
I have created a RadGrid with SqlDataSource. Enabled Automatic delete, update and insert. Then I created an external filter with ComboBox, for filtering with multiple columns. I created a function for filtering in code behind with new Sql connection and Rebind RAdGrid with new filtered items. When I run Its perfect every automatic properties work. But after filtering with combobox automatic properties does n't work, not able to edit delete paging sorting etc. The reason is I am binnding the grid with new data table for filtering. How can I enable the automatic properties again, after filtering? Anybody can help.
 I tryied to write, RadGrid.AutomaticDelete=true, AutomaticUpdate=true, etc in codebehind after binding with filtered data. But no hope.

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Oct 2010, 08:17 AM
Hi Ben,

If you change the parameters of your data source controls, you need to ensure the new data source control setup also supports automatic data operations (e.g. it has its SELECT, INSERT, UPDATE, DELETE command and parameters matching RadGrid's setup. If you do not get automatic CRUD operations with RadGrid after filtering, it probably means RadGrid does not find the the data source settings that it needs.

Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ben
Top achievements
Rank 1
answered on 21 Oct 2010, 01:23 PM
Thank you for your answer
I have just Select statement in my new sqldatasource in codebehind. This is my code. what is wrong with this code. I want to get automatic oeprations after this radgrid binding. How to create new datasource control

                 

                string fullString = RadComboBox1.SelectedValue.ToString();

                string firstString = fullString.Substring(0, 3); //Extracting substring

                string middleString = fullString.Substring(3, 7); //Extracting substring
                string lastString = fullString.Substring(11, 1);

                SqlCommand cmd = new SqlCommand("Select * from  PWOPENITEMS WHERE (((OPCODE = @OPCODE)AND (FLEET = @FLEET)) AND (SUBFLEET = @SUBFLEET))", con);
                SqlParameter OpcParam = new SqlParameter("@OPCODE", firstString);
                OpcParam.SqlDbType = SqlDbType.VarChar;
                OpcParam.Size = 3;
                cmd.Parameters.Add(OpcParam);

                SqlParameter FleetParam = new SqlParameter("@FLEET", middleString);
                FleetParam.SqlDbType = SqlDbType.VarChar;
                FleetParam.Size = 7;
                cmd.Parameters.Add(FleetParam);

                SqlParameter SubFleetParam = new SqlParameter("@SUBFLEET", lastString);
                SubFleetParam.SqlDbType = SqlDbType.VarChar;
                SubFleetParam.Size = 2;
                cmd.Parameters.Add(SubFleetParam);
                //Response.Write(SubFleetParam.Value);

                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                DataSet datas = new DataSet();
                da.Fill(datas, "tbl_data");
                if (datas.Tables["tbl_data"].Rows.Count != 0)
                {   
                    RadGridOpenItems.DataSourceID = String.Empty;
                    RadGridOpenItems.DataSource = datas;
                    RadGridOpenItems.DataBind();

                }
                else
                {
                    Response.Write("No DATA");

                }

0
Veli
Telerik team
answered on 26 Oct 2010, 11:59 AM
Hello Ben,

In your code, you are manually opening a connection to your database and getting the grid data with the use of SqlCommand and SqlDataAdapter classes. This is different from using declarative DataSource controls to bind RadGrid. Please refer to the RadGrid automatic data source operations demo. We have used another data source control (the SessionDataSource) for databinding RadGrid. DataSource controls simplify database connection and CRUD operations. Here is an MSDN article to get you started with Data Source control.

Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Veli
Telerik team
Ben
Top achievements
Rank 1
Share this question
or