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

Grid view row count

3 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ganeshkumar
Top achievements
Rank 1
Ganeshkumar asked on 28 Mar 2016, 06:36 AM

Hi,

In my project we are replacing the grid view controls in to Rad Grid controls.

Please let me know how to implement the below code through the Rad Grid control.

for (int i = 0; i < gvEmployee.Rows.Count; i++)
{
employee = ((DropDownList)gvEmployee.Rows[i].FindControl("ddlEmployee")).SelectedValue;
for (int j = i + 1; j < gvEmployee.Rows.Count; j++)
{
if (string.Compare(employee, ((DropDownList)gvLOB.Rows[j].FindControl("ddlEmployee")).SelectedValue) == 0 && employee != "--SELECT--")
{
DoAlert("Please select distinct " + gvHeaderemployee);
return;
}
}
if (employee != "--SELECT--")
{
dtemployeelocal.Rows.Add(employee);
}
}

I need to check the distinct record added in my grid view on Submit button click event

 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 29 Mar 2016, 10:05 AM
Hi Ganeshkumar,

In order to validate the data edited in the RadGrid before persisting it to the data source you can use manual CRUD operations. You should handle the UpdateCommand/InsertCommand events of the grid and validate the input. In case the new data passes validation you can update the data source.

Check out the following online example that illustrates how you can implement manual CRUD operations in RadGrid. You can use it as a starting point in your scenario. Note that you should add validation for the updated data.



Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Ganeshkumar
Top achievements
Rank 1
answered on 31 Mar 2016, 04:16 AM

Hi Viktor,

Thanks for your prompt reply.

But in my page we use common submit button to save all the data into DB. We are not using edit button in the Gridview.

We are validating the Gridview data in the button click event only.

Regards,

Ganeshkumar

 

0
Viktor Tachev
Telerik team
answered on 04 Apr 2016, 07:53 AM
Hello Ganeshkumar,

If you would like to submit all changes in the grid with a single request you should consider enabling Batch Edit mode. In this editing mode you can handle the OnBatchEditCommand event of RadGrid and iterate through the changes. Check out the following resources that describe the functionality in more detail.



Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Ganeshkumar
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Ganeshkumar
Top achievements
Rank 1
Share this question
or