Hi everyone!
I have a webform include gridview and some controls.
I merged cells in RowDatabound event:
Private Sub grvData_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grvData.RowDataBound
Try
If e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells.RemoveAt(e.Row.Cells.Count - 1)
e.Row.Cells(e.Row.Cells.Count - 1).ColumnSpan = 2
e.Row.Cells(e.Row.Cells.Count - 1).Text = "Thao tác"
End If
If e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells.RemoveAt(e.Row.Cells.Count - 1)
e.Row.Cells.RemoveAt(e.Row.Cells.Count - 1)
e.Row.Cells.RemoveAt(e.Row.Cells.Count - 1)
e.Row.Cells(e.Row.Cells.Count - 1).ColumnSpan = 4
End If
Catch ex As Exception
Throw New Exception(ex.Message, ex)
End Try
End Sub
The webform as below image:
01.jpg - Google Drive[
^]
In the Gridview footer, when i click button "Thêm mới" to call event RowCommand of gridview:
Private Sub grvData_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grvData.RowCommand
lblError.Text = String.Empty
Dim commandNameType As String = String.Empty
Try
If e.CommandName = "Insert" Then
commandNameType = "thêm"
Dim txtName As TextBox = DirectCast(grvData.FooterRow.FindControl("txtNewName"), TextBox)
If String.IsNullOrEmpty(txtName.Text) Then
Return
End If
lblError.text = "Đã tồn tại nguồn đơn . Bạn không thể tạo thêm được nguồn đơn này nữa"
Return
End If
Catch ex As Exception
lblError.Text = "Lỗi không " & commandNameType & " được bản ghi này <br />" & ex.Message
End Try
And then, the Label lblError display text then my form lost format as below:
02.jpg - Google Drive[
^]
How to keep format after click "Thêm mới" button?
What I have tried:
I tried use UpdatePanel but cannot solved.