::: Getting run time control of the grid view inside the RowDataBound method.
Private Sub GridView1_RowDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Handles GridView1.RowDataBound
If CType(e.Row.FindControl("LblLanguagesCode"), Label).Text = "" Then
e.Row.Cells(2).Text = ""
End If
End Sub
::: Getting datakeynames of the grid view inside the RowDataBound method.
Private Sub Grid_Work_Experience_RowDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
Handles Grid_Work_Experience.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim Employer As String = Grid_Work_Experience.DataKeys(e.Row.RowIndex).Values("Employer") & "" Dim Position As String = Grid_Work_Experience.DataKeys(e.Row.RowIndex).Values("Position") & "" If Employer <> "" Then e.Row.Cells(3).Text = Employer End If If Position <> "" Then e.Row.Cells(3).Text = Employer & " / " & Position End If End If End Sub
::: Finding the control of selected row inside the RowUpdating method
Private Sub GridView1_RowUpdating(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)Handles GridView1.RowUpdating Dim Continent_Name As String = CType(Me.GridView1.Rows(e.RowIndex).FindControl("TxtContinentNameEdit"), TextBox).Text If Continent_Name = "" Then CType(Me.AlertMessageBox1.FindControl("lblMessage"), Label).Text = "Please input Continent Name field !!!" Me.Mpe_AlertMessage.Show() Me.ShowContinentData() CType(Me.DtgContinent.Rows(e.RowIndex).FindControl("TxtContinentNameEdit"), TextBox).Text = Continent_Name End If End Sub
::: Finding the control of gridview inside the normal method
Protected Sub ImgSaveAddNew_Click(ByVal sender As Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Dim Languages_Name As String = CType(Me.GridView1.FooterRow.FindControl("TxtLanguagesNameAddNew"), TextBox).Text End Sub
No comments:
Post a Comment