Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > EditItemTemplate question

Reply
Thread Tools

EditItemTemplate question

 
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
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(.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
 
Reply With Quote
 
 
 
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
e.Item.Controls.FindControl("TextBox's Id").Visible = false;



"NH" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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(.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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
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?

"Grant Merwitz" wrote:

> e.Item.Controls.FindControl("TextBox's Id").Visible = false;
>
>
>
> "NH" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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(.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

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
the line its failing on is
CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False

Its says "Input string was not in a correct format. "

"NH" wrote:

> 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?
>
> "Grant Merwitz" wrote:
>
> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
> >
> >
> >
> > "NH" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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(.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

> >
> >
> >

 
Reply With Quote
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
i think it should be

CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"), TextBox).Enabled =
False

Adding the 'FindControl' in there

"NH" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> the line its failing on is
> CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
>
> Its says "Input string was not in a correct format. "
>
> "NH" wrote:
>
>> 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?
>>
>> "Grant Merwitz" wrote:
>>
>> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
>> >
>> >
>> >
>> > "NH" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> > > 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(.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
>> >
>> >
>> >



 
Reply With Quote
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
Yes I tried that but it says "FindControl" is not a member of
System.Web.UI.ControlCollection"

thanks

"Grant Merwitz" wrote:

> i think it should be
>
> CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"), TextBox).Enabled =
> False
>
> Adding the 'FindControl' in there
>
> "NH" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > the line its failing on is
> > CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
> >
> > Its says "Input string was not in a correct format. "
> >
> > "NH" wrote:
> >
> >> 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?
> >>
> >> "Grant Merwitz" wrote:
> >>
> >> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
> >> >
> >> >
> >> >
> >> > "NH" <(E-Mail Removed)> wrote in message
> >> > news:(E-Mail Removed)...
> >> > > 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(.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
> >> >
> >> >
> >> >

>
>
>

 
Reply With Quote
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
sorry, drop out the control bit

e.Item.FindControl("MyControl")


"NH" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes I tried that but it says "FindControl" is not a member of
> System.Web.UI.ControlCollection"
>
> thanks
>
> "Grant Merwitz" wrote:
>
>> i think it should be
>>
>> CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"), TextBox).Enabled
>> =
>> False
>>
>> Adding the 'FindControl' in there
>>
>> "NH" <(E-Mail Removed)> wrote in message
>> news(E-Mail Removed)...
>> > the line its failing on is
>> > CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
>> >
>> > Its says "Input string was not in a correct format. "
>> >
>> > "NH" wrote:
>> >
>> >> 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?
>> >>
>> >> "Grant Merwitz" wrote:
>> >>
>> >> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
>> >> >
>> >> >
>> >> >
>> >> > "NH" <(E-Mail Removed)> wrote in message
>> >> > news:(E-Mail Removed)...
>> >> > > 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(.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
>> >> >
>> >> >
>> >> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
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?

"Grant Merwitz" wrote:

> sorry, drop out the control bit
>
> e.Item.FindControl("MyControl")
>
>
> "NH" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yes I tried that but it says "FindControl" is not a member of
> > System.Web.UI.ControlCollection"
> >
> > thanks
> >
> > "Grant Merwitz" wrote:
> >
> >> i think it should be
> >>
> >> CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"), TextBox).Enabled
> >> =
> >> False
> >>
> >> Adding the 'FindControl' in there
> >>
> >> "NH" <(E-Mail Removed)> wrote in message
> >> news(E-Mail Removed)...
> >> > the line its failing on is
> >> > CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
> >> >
> >> > Its says "Input string was not in a correct format. "
> >> >
> >> > "NH" wrote:
> >> >
> >> >> 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?
> >> >>
> >> >> "Grant Merwitz" wrote:
> >> >>
> >> >> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
> >> >> >
> >> >> >
> >> >> >
> >> >> > "NH" <(E-Mail Removed)> wrote in message
> >> >> > news:(E-Mail Removed)...
> >> >> > > 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(.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
> >> >> >
> >> >> >
> >> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
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'


"NH" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
> "Grant Merwitz" wrote:
>
>> sorry, drop out the control bit
>>
>> e.Item.FindControl("MyControl")
>>
>>
>> "NH" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Yes I tried that but it says "FindControl" is not a member of
>> > System.Web.UI.ControlCollection"
>> >
>> > thanks
>> >
>> > "Grant Merwitz" wrote:
>> >
>> >> i think it should be
>> >>
>> >> CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"),
>> >> TextBox).Enabled
>> >> =
>> >> False
>> >>
>> >> Adding the 'FindControl' in there
>> >>
>> >> "NH" <(E-Mail Removed)> wrote in message
>> >> news(E-Mail Removed)...
>> >> > the line its failing on is
>> >> > CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
>> >> >
>> >> > Its says "Input string was not in a correct format. "
>> >> >
>> >> > "NH" wrote:
>> >> >
>> >> >> 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?
>> >> >>
>> >> >> "Grant Merwitz" wrote:
>> >> >>
>> >> >> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > "NH" <(E-Mail Removed)> wrote in message
>> >> >> > news:(E-Mail Removed)...
>> >> >> > > 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(.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
>> >> >> >
>> >> >> >
>> >> >> >
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?Tkg=?=
Guest
Posts: n/a
 
      08-11-2005
No, tired that too, but got the same Object reference not set to an instance
of an object" error.

Is there a way of doing this? It should be simply!!

"Grant Merwitz" wrote:

> 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'
>
>
> "NH" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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?
> >
> > "Grant Merwitz" wrote:
> >
> >> sorry, drop out the control bit
> >>
> >> e.Item.FindControl("MyControl")
> >>
> >>
> >> "NH" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Yes I tried that but it says "FindControl" is not a member of
> >> > System.Web.UI.ControlCollection"
> >> >
> >> > thanks
> >> >
> >> > "Grant Merwitz" wrote:
> >> >
> >> >> i think it should be
> >> >>
> >> >> CType(e.Item.Controls.FindControl("txtDaysWriteOff ed"),
> >> >> TextBox).Enabled
> >> >> =
> >> >> False
> >> >>
> >> >> Adding the 'FindControl' in there
> >> >>
> >> >> "NH" <(E-Mail Removed)> wrote in message
> >> >> news(E-Mail Removed)...
> >> >> > the line its failing on is
> >> >> > CType(e.Item.Controls("txtDaysWriteOffed"), TextBox).Enabled = False
> >> >> >
> >> >> > Its says "Input string was not in a correct format. "
> >> >> >
> >> >> > "NH" wrote:
> >> >> >
> >> >> >> 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?
> >> >> >>
> >> >> >> "Grant Merwitz" wrote:
> >> >> >>
> >> >> >> > e.Item.Controls.FindControl("TextBox's Id").Visible = false;
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > "NH" <(E-Mail Removed)> wrote in message
> >> >> >> > news:(E-Mail Removed)...
> >> >> >> > > 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(.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
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid boundcolumn and edititemtemplate question needin4mation@gmail.com ASP .Net 1 06-22-2005 06:35 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
CustomValidator in the EditItemTemplate of a DataGrid Dave ASP .Net 1 10-31-2003 07:10 AM
Datalist EditItemTemplate SStory ASP .Net 0 08-18-2003 11:01 PM
datagrid edititemtemplate for dates Trevor Hartman ASP .Net 0 07-16-2003 06:46 PM



Advertisments