GOT IT
After much fighting with Visual Studio - which kept removing my DataGrid
events, i found a way
In your EditCommand method, hide the Column you don't want to show,
So, if the TextBox will appear in Column 4, in you EditCommand Method do
as
follows:
private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DatGrid1.EditItemIndex = e.Item.ItemIndex;
BindTopicGrid(this.m_user);
if(e.Item.Cells(8).Text = "2" then
DataGrid1.Columns[4].Visible = false;
End If
}
Again, HTH
NH said:
tried that too, go the same object not set...error
This should be a simple thing to do, any other ideas? I am tried
everything
I know...
:
How about if you try that code in the EditCommand
private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
e.Item.FindControl("");
}
not sure the VB code for that, but accessed through the DataGrid
property
'EditCommand'
Yeah this is something I tried also, get an ""Object reference not
set
to
an
instance of an object" error.
It looks like the EditItemTemplate control is not referenceabnle in
the
ItemDataBound event?
:
sorry, drop out the control bit
e.Item.FindControl("MyControl")
Yes I tried that but it says "FindControl" is not a member of
System.Web.UI.ControlCollection"
thanks
:
i think it should be
CType(e.Item.Controls.FindControl("txtDaysWriteOffed"),
TextBox).Enabled
=
False
Adding the 'FindControl' in there
the line its failing on is
CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled =
False
Its says "Input string was not in a correct format. "
:
thanks for the reply.
I get a "Object reference not set to an instance of an
object"
error
with
the line
CType(e.Item.FindControl("txtDaysWriteOffed"),
TextBox).Visible
=
False
Should the EditItemTemplate control be referenceable in the
ItemDataBound
datagrid event? Its as if it doesnt know about the control?
:
e.Item.Controls.FindControl("TextBox's Id").Visible =
false;
How can I only display the textbox I have in an
EditItemTemplate
based on
the
value in another cell in the row?
i.e I only want users to edit one of the cells based on
the
value
in
another
cell....
Should I do this in the ItemDataBound event of the
datagrid...something
like...
If e.Item.Cells(8).Text = "2" Then
dont allow the textbox defined in the
EditItemTemplate
to
be
visible
what is the code for this?
End If
Thanks for your help