I have this code in the itemdatabound event..
If e.Item.Cells(8).Text = "2" Then
Dim t As TextBox =
DirectCast(e.Item.FindControl("txtPendingEd"), TextBox)
If Not t Is Nothing Then
t.Visible = False
End If
End If
e.Item.Cells(1).ToolTip = e.Item.Cells(7).Text
I have debugged and there are rows in the grid with cell(8) text of "2" yet
the TextBox declared above is always "nothing".
Does anyone have any code that they can test this in. I really cannot get
what seems like a simple thing to work.
"dotnettester" wrote:
> can't you make visible = false? for the text box? and if you need to make it
> visible in postback , just set visible = true for the text box.
>
> ?
>
> "NH" wrote:
>
> > Hi,
> > thanks for the response. It doesnt quite work however.
> >
> > It has strange behaviour, the textbox in the edititemtemplate is always read
> > only regardless of my check. Even if I comment out the "txtNewBox.readonly =
> > true" code it is still read only.
> >
> > But anyways what I would like to do is not to display the txtNewBox at all
> > as opposed to just making it read only. Am I right in putting this code in
> > the itemdatabound event of the datagrid?
> >
> > "Sachin Saki" wrote:
> >
> > >
> > >
> > > "NH" ने लिखा:
> > >
> > > > Hi,
> > > > I just cannot get this to work. I want to make a cell editable in a datagrid
> > > > only if the value of another cell is something specific.
> > > >
> > > > I am able to capture the value of the other cell via the ItemDataBound event
> > > > of the datagrid e.g.
> > > > If e.Item.Cells(8).Text = "2" Then
> > > > 'Make the textbox defined in my edititemtemplate read only of invisible
> > > > End If
> > > >
> > > > But now I just dont know how to prevent the user modifying the value of the
> > > > cell, it would be great if the edititemtemplate textbox just stayed invisible
> > > > whenever the user tries to edit the row where the value of the other cell is
> > > > e.g. 2.
> > > >
> > > > Help really appreciated.
> > > > But
> > >
> > > If e.Item.Cells(8).Text = "2" Then
> > > > 'Make the textbox defined in my edititemtemplate read only of invisible
> > > ''Whenever you find the value 2 you can find the textbox in that
> > > row in itemdatabound event
> > > Dim txtNewBox as textbox = DirectCast(e.item.FindControl("id of
> > > textbox"),textbox)
> > > If Not txtNewBox is nothing then
> > > ' Here you can set text box property
> > > txtNewBox.readonly = true
> > > End If
> > > End If
> > >
> > > I hope this will work for you. Let me know if any concerns
> > >
> > > Regards,
> > > Sachin Saki
|