วันพุธที่ 4 มิถุนายน พ.ศ. 2557

GridView1 RowDataBound (DataControlRowType.Footer)

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
    CssClass="table table-striped table-bordered table-hover" DataKeyNames="slide_ID" DataSourceID="LinqDataSource1" GridLines="None">
    <Columns>
        <asp:BoundField DataField="slide_type" HeaderText="ประเภท" SortExpression="slide_type">
        <HeaderStyle Width="150px" />
        <ItemStyle HorizontalAlign="Center" />
        </asp:BoundField>
        <asp:BoundField DataField="slide_img" HeaderText="ตำแหน่งรูปภาพ" SortExpression="slide_img" />
        <asp:CommandField ButtonType="Button" SelectText="แก้ไข" ShowSelectButton="True" />
       <asp:TemplateField >
           <ItemTemplate >
               <asp:HiddenField ID="hddslide_ID" runat="server" Value ='<%# Eval("slide_ID")%>'  />
           </ItemTemplate>
       </asp:TemplateField>
    </Columns>
</asp:GridView>
<div class="pull-right well" >
    <div class =""> ผลรวม :
            <asp:Literal ID="ltrSum" runat="server"></asp:Literal>
        </div>
</div>
   
**********************************************************
Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Try

                Dim hddslide_ID As HiddenField = CType(e.Row.FindControl("hddslide_ID"), HiddenField)

                sum = sum + Val(hddslide_ID.Value)


            Catch ex As Exception

            End Try
        End If

        If e.Row.RowType = DataControlRowType.Footer Then
            ltrSum.Text = sum
        End If

    End Sub

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

การใช้ WebClient สำหรับเรียก URL

Dim _url As String = " https :// www . MyDomain . com /?q=ทดสอบ " Dim wc As New System . Net . WebClient () wc . Encodin...