How to save dynamic grid data to database?

Does anybody know how to save grid data to database on saveClickListener and how can we save the edited grid data to ``exact same row?
I may not be able to ask the question properly? But If anyone know the proper way please help.
Help would be greatly appreciated. Thanks!

I tried something from my side but I don’t think this is a feasible way! (“What if we enter some new entries to grid?”)

	public void getDataFromGrid() {
		ListDataProvider<DemoObjectPrioritization> s = (ListDataProvider<DemoObjectPrioritization>) getGrid().getDataProvider();
		ArrayList<DemoObjectPrioritization> s1 = (ArrayList<DemoObjectPrioritization>)s.getItems();
		String A =s1.get(0).getSevernity_c1_none();
		String B =s1.get(1).getSevernity_c1_none();
		String C =s1.get(2).getSevernity_c1_none();
		String D =s1.get(0).getSevernity_c2_minor();
		String E =s1.get(1).getSevernity_c2_minor();
		String F =s1.get(2).getSevernity_c2_minor();
		String G =s1.get(0).getSevernity_c3_major();
		String H =s1.get(1).getSevernity_c3_major();
		String I =s1.get(2).getSevernity_c3_major();
		String J =s1.get(0).getSevernity_c4_severe();
		String K =s1.get(1).getSevernity_c4_severe();
		String L =s1.get(2).getSevernity_c4_severe();
		dataModal = new GridEdittedPrioritizationDataModal(A, B, C, D, E, F, G, H, I, J, K, L);;