Trace.Write ("What type is this
control",e.Item.Cells[0].Controls[0].GetType().ToString());


On 12/1/05, Mark E <[EMAIL PROTECTED]> wrote:
>  I get the following error when I add that line:
>
>    Method 'Object.GetType()' referenced without parenthesis
>
>    So I updated the link to include the parens, like so:
>
>    Trace.Write ("What type is this
> control",e.Item.Cells[0].Controls[0].GetType());
>
>    And I get this error:
>
>    The best overloaded method match for
> 'System.Web.TraceContext.Write(string, string)' has some invalid arguments
>
>    Do I need to convert the object to a string?
>
>
>  Charles Carroll <[EMAIL PROTECTED]> wrote:
>    string strUpdatedStatusName =
> ((TextBox)e.Item.Cells[0].Controls[0]).Text;
>
>  change to
>  // string strUpdatedStatusName =
> ((TextBox)e.Item.Cells[0].Controls[0]).Text;
>  Trace.Write ("What type is this
> control",e.Item.Cells[0].Controls[0].GetType)
>
>  and add Trace="true" to page.
>
>  then you will see what that control really is.....
>
>  On 12/1/05, Mark E <[EMAIL PROTECTED]> wrote:
>  >  Hi all,
>  >
>  >    I'm trying to get values from 2 texboxes from a datagrid for an item
> that
>  > allows edits.
>  >
>  >    Here is the code that I'm using to fetch my value from the first
> control
>  > in the first column of the datagrid:
>  >
>  >      string strUpdatedStatusName =
>  > ((TextBox)e.Item.Cells[0].Controls[0]).Text;
>  >
>  >    But I'm getting this error:
>  >
>  >    System.InvalidCastException: Specified cast is not valid.
>  >
>  >    Here's my datagrid:
>  >
>  >    <asp:DataGrid ID="dgrStatusList" Width="98%"
>  > OnEditCommand="dgrStatusList_Edit"
>  > OnUpdateCommand="dgrStatusList_Update"
>  > PagerStyle-Mode="NumericPages"
>  > OnCancelCommand="dgrStatusList_Cancel"
> CssClass="TableText"
>  > DataKeyField="Status_ID" AutoGenerateColumns="False"
>  > HeaderStyle-BackColor="#c0c0c0"
>  > HeaderStyle-CssClass="sideNavLinkHeaderText"
> Runat="server"
>  > AlternatingItemStyle-BackColor="#e0e0e0">
>  >           <Columns>
>  >            <asp:TemplateColumn HeaderStyle-Width="40%">
>  >             <HeaderTemplate>
>  >              Status
>  >             </HeaderTemplate>
>  >             <ItemTemplate>
>  >              <%# DataBinder.Eval(Container.DataItem, "Status_Name") %>
>  >             </ItemTemplate>
>  >             <EditItemTemplate>
>  >              <asp:TextBox ID="txtUpdatedStatusName" Text='<%#
>  > DataBinder.Eval(Container.DataItem, "Status_Name") %>'
>  > CssClass="RegularText" Runat="server"></asp:TextBox>
>  >              <asp:RequiredFieldValidator
>  > ControlToValidate="txtUpdatedStatusName" Text="*
> Required"
>  > CssClass="SmallRedConfirmText" Runat="server"
> ID="Requiredfieldvalidator1"
>  >
> NAME="Requiredfieldvalidator1"></asp:RequiredFieldValidator>
>  >             </EditItemTemplate>
>  >            </asp:TemplateColumn>
>  >
>  >            <asp:TemplateColumn HeaderStyle-Width="20%">
>  >             <HeaderTemplate>
>  >              Sort Order
>  >             </HeaderTemplate>
>  >             <ItemTemplate>
>  >              <%# DataBinder.Eval(Container.DataItem, "Sort_Order") %>
>  >             </ItemTemplate>
>  >               <EditItemTemplate>
>  >              <asp:TextBox ID="txtUpdatedStatusSortOrder" Text='<%#
>  > DataBinder.Eval(Container.DataItem, "Sort_Order") %>'
>  > CssClass="EvenSmallerBox" Runat="server"></asp:TextBox>
>  >              <asp:RequiredFieldValidator
>  > ControlToValidate="txtUpdatedStatusSortOrder" Text="*
>  > Required" CssClass="SmallRedConfirmText" Runat="server"
>  > ID="Requiredfieldvalidator2"
>  >
> NAME="Requiredfieldvalidator1"></asp:RequiredFieldValidator>
>  >             </EditItemTemplate>
>  >
>  >            </asp:TemplateColumn>
>  >
>  >            <asp:TemplateColumn HeaderStyle-Width="15%">
>  >             <HeaderTemplate>
>  >              Delete
>  >             </HeaderTemplate>
>  >             <ItemTemplate>
>  >              &nbsp;[<a
>  > href="javascript:onClick=ConfirmDelete('Status', <%#
>  > DataBinder.Eval(Container.DataItem, "Status_ID") %>);">delete</a>]
>  >             </ItemTemplate>
>  >            </asp:TemplateColumn>
>  >            <asp:EditCommandColumn EditText="Edit" UpdateText="Update"
>  > CancelText="Cancel"></asp:EditCommandColumn>
>  >           </Columns>
>  >          </asp:DataGrid>
>  >
>  >    I can do this in VB.NET but cannot seem to get it to work in C#.  Any
>  > ideas?
>  >
>  >    Thanks,
>  >    Mark


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/u8TY5A/tzNLAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to