Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello...


i am using gridview with 11 fields but i need to check only 4 fields so i took 7 8 9 10 cell values from grid...in gridview i am using like this but with 11 fields

ASP.NET
<asp:GridView ID="show_moreDetails" runat="server" AutoGenerateColumns="False"
           Width="400px" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
           BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black">
           <RowStyle BackColor="White" />
           <Columns>
               <asp:TemplateField>
                   <ItemTemplate>
                       <table style="width: 100%;font-size:16px;font-family:Times New Roman;letter-spacing:1px"  class="altrowstable" id="alternatecolor">
                           <tr>
                               <td>
                                   Name
                               </td>
                               <td>
                                   :
                               </td>
                               <td>
                                   <asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Dealer_name") %>'></asp:Label>
                               </td>
                           </tr>
                           <tr>
                               <td>
                                   Message
                               </td>
                               <td>
                                   :
                               </td>
                               <td>
                                   <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"message") %>'></asp:Label>
                               </td>
                           </tr>
                           <tr>
Posted
Updated 12-May-12 0:31am
v2
Comments
OriginalGriff 12-May-12 7:08am    
And?
Your question is?
RDBurmon 12-May-12 7:31am    
and the question is ?

1 solution

I see, this is a continuation of your previous question[^]. Now, if you see, you have put one template field and added table rows in it with all your columns. Hence when you try to find values in Column 7,8 or so, you get index out of range.

Each template field here corresponds to one column. Now, do you math and put logic to see how many columns you have and if you are poiniting to correct column for extracting data.

Try: separate all rows - name, message, etc in different template fields.

Use Visual Studio DEBUGGER to check the column counts and appropriately call/use them.
If needed, read about template fields here: MSDN: Using TemplateFields in the GridView Control[^]


P.S.: Now, in response to this question/answer, don't create a new question. That confuses new user when they see your followup question.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900