TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Danish Habib
NA
694
244.4k
how To disable textbox inside gridview
Jan 1 2015 11:12 PM
How to disable textboxes inside gridview Edititem section based on some condition below is the code which says object reference is not set
Private Sub grdUserReport_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdUserReport.RowDataBound
For Each row As GridViewRow In grdUserReport.Rows
If row.RowType = DataControlRowType.DataRow Then
For i As Integer = 1 To row.Cells.Count - 1
If row.Cells(i).Controls.OfType(Of TextBox)().ToList().Count > 0 Then
' row.Cells(i).Controls.OfType(Of TextBox)().FirstOrDefault().Visible = isChecked
row.Cells(i).Controls.OfType(Of TextBox)().FirstOrDefault().Enabled = True
End If
Dim country As String = TryCast(row.Cells(0).FindControl("litType"), Label).Text
Dim strColumn As String = DataBinder.Eval(e.Row.DataItem, "ControlScr").ToString
' Dim check As String = TryCast(row.Cells(1).FindControl("litStatus"), Label).Text
' Dim txtForboy As String = TryCast(row.Cells(0).FindControl("QTotal"), Literal).Text
Dim txtBoxMen As TextBox = TryCast(grdUserReport.HeaderRow.FindControl("QTotal"), TextBox)
If country.Trim() = "DQTwoValueInteger.ascx" Then
txtBoxMen.Enabled = False
row.Cells(1).Controls.OfType(Of TextBox)().FirstOrDefault().Enabled = False
row.Cells(9).Controls.OfType(Of TextBox)().FirstOrDefault().Enabled = False
row.Cells(10).Controls.OfType(Of TextBox)().FirstOrDefault().Enabled = False
row.Cells(6).Controls.OfType(Of TextBox)().FirstOrDefault().Enabled = False
End If
Next
End If
Next
End Sub
Reply
Answers (
2
)
Gridview Cell splitting
Add li link name in iframe in asp.net c#