Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 625917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:21:44+00:00 2026-05-13T19:21:44+00:00

i am usin rowdatabound event of gridview to do some formating in gridview column.

  • 0

i am usin rowdatabound event of gridview to do some formating in gridview column. But when i execute the code and debug it using immediate window i do not get anything in e.Row.Cells[1].Text. I am populating the gridview from a datatable. It is displaying the records but i dont know why is it not getting in rowdatabound.
following is my code for binding

<asp:GridView runat="server" AutoGenerateColumns="False"  
                        ID="gviewTemplate" onrowdatabound="gviewTemplate_RowDataBound" DataKeyNames="F1"
                        onrowcommand="gviewTemplate_RowCommand" 
                        onrowediting="gviewTemplate_RowEditing" 
                        onrowcancelingedit="gviewTemplate_RowCancelingEdit" 
                        onrowupdating="gviewTemplate_RowUpdating">
                        <Columns>
                            <asp:TemplateField>
                                <EditItemTemplate>
                                    <asp:Label ID="lblID" runat="server" Text='<%# Bind("F1") %>'></asp:Label>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label Runat="server" Text='<%# Bind("F1") %>' ID="lblID1"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Uploaded Image">
                            <EditItemTemplate>
                                <asp:LinkButton Text="Reload" runat="server" CommandArgument='<%# Bind("F1") %>' CommandName="reload" ID="lbtnReloadImage"></asp:LinkButton>
                            </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label Runat="server" Text='<%# Eval("Uploaded") %>' ID="lblUploaded"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Template Name">
                                <ItemStyle VerticalAlign="Top" HorizontalAlign="Center" />
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtTemplateName" Width="50" Runat="server" Text='<%# Eval("F2") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" 
                                    ErrorMessage="You must provide a Product Name." ControlToValidate="txtTemplateName">*</asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblTemplateName" runat="server" Text='<%# Eval("F2") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Heading">
                                <ItemStyle VerticalAlign="Top" HorizontalAlign="Center" />
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtHeading" Runat="server" Width="50" Text='<%# Eval("F3") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server" 
                                    ErrorMessage="You must provide a Product Name." ControlToValidate="txtHeading">*</asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblHeading" runat="server" Text='<%# Eval("F3") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Coupon Text">
                                <ItemStyle VerticalAlign="Top" HorizontalAlign="Center" />
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtCouponText" Runat="server" Width="50" Text='<%# Bind("F4") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" Runat="server" 
                                    ErrorMessage="You must provide a Product Name." ControlToValidate="txtCouponText">*</asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label Runat="server" Text='<%# Bind("F4") %>' ID="lblCouponText"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

and this is what i am doing in rowdatabound

protected void gviewTemplate_RowDataBound(object sender, GridViewRowEventArgs e)
{
        if (e.Row.Cells[1].Text != e.Row.Cells[2].Text)
        {
            e.Row.BackColor = System.Drawing.Color.Red;
        }
 }

i cant understand if the records are being displayed in grid the why cant i get it in rowdatabound

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:21:45+00:00Added an answer on May 13, 2026 at 7:21 pm

    Because you are using the template field in the grid , so try to debug and hold the cell then try to find the textbox inside it and then read it’s value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to download a folder using wget on the Terminal (I'm usin a
I used the below code to do the aove task: Dim Arr(2,150) Arr(0)=objsheet.Range(B16:B225).Value But
I'm not quite sure stackoverflow is a place for such a general question, but
I am using google map in my site i added some user define icon
I am trying to rotate vectors using matrices, but got confused. I thought all
I'm usin Windows.Forms aplication and I can get files or directory from my user
I am usin the nsxmlparser and am wondering how I can parse ISO-8859-1 correctly
i configured log4j for basic purpose usin the conversion pattern :- log4j.appender.rollingFile.layout.ConversionPattern=%p %t %c
i have a Log on in APS MVC 2.0 and if not logged on,
I can't understand general scheme using certificates. For example: I have account on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.