有问题或评论 [英] Have Question or comment

查看:93
本文介绍了有问题或评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...


我正在使用带有11个字段的gridview,但是我只需要检查4个字段,所以我从grid中获取了7 8 9 10个单元格的值...在gridview中,我像这样使用,但是有11个字段

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: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>

推荐答案

我知道,这是您 MSDN:在GridView控件中使用TemplateFields [ ^ ]


附注:现在,针对这个问题/答案,请勿创建新问题.当新用户看到您的跟进问题时,这会使他们感到困惑.
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.


这篇关于有问题或评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆