Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!

I have a webform include gridview and some controls.
I merged cells in RowDatabound event:
VB
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:
VB
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.
Posted
Updated 18-Apr-16 20:24pm
v4
Comments
manticohd 19-Apr-16 23:20pm    
some one help me please

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900