how can i get the index of the new record in the radgrid to insert value programataclly

0 Answers 61 Views
Grid
khaled
Top achievements
Rank 1
Iron
khaled asked on 18 Oct 2021, 06:34 PM

I need to insert a value in a cell from another radtree value in server side but the problem is i can not know the current index when the record is new record, the 0 index update the first record not the new record

       Dim ItemGrid As RadGrid = CType(Page.Master.FindControl("MainContent").FindControl("RadGrid2"), RadGrid)
                Dim dataItm As GridDataItem = TryCast(ItemGrid.MasterTableView.Items(0), GridDataItem)
                Dim cell As TableCell = dataItm("price")
                cell.Text = Convert.ToString(myreader("Unit_Price"))
                cell.Focus()
                cell.BorderColor = Color.Red
Attila Antal
Telerik team
commented on 21 Oct 2021, 10:38 AM

Hi Khaled.

I understand that you are trying to use the Row index to create an ID for the new, record. Is that correct? Using a row index as the ID of a new record is incorrect. Upon inserting a new value in the Database, the database Table must have an ID field that is automatically incremented. So you will only need to insert the Known values because the ID will be automatically generated for it. The next time you update this record, you will be referring to the ID.

If my assumption is incorrect, please share more details about the project. I would need to see how the Grid and TreeView are configured. (ASPX and ASPX.CS/VB). That will help me understand what you were after and I might be able to suggest you a better approach.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
khaled
Top achievements
Rank 1
Iron
Share this question
or