webgrid issue about CellTemplate using DataBinder

4 replies. Last post: July 29, 2011 6:09 AM by Riendy Setiadi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
xu guochunMember

Hello,

we are using WebGrid 7 and  having a strange problem.

<ISWebGrid:WebGrid ID="GridHandle" runat="server" Width="99%" OnInitializeRow="WebGrid1_InitializeRow"
    UseDefaultStyle="True" DataSourceID="ISDataSource1" DataMember="Messages_Center">
    <LayoutSettings AllowSorting="No" AutoFitColumns="true" PagingLoadMode="Custom" AllowGrouping="No" PagingMode="ClassicPaging" PagingSize="20">
        <TextSettings Language="UseCustom" UseLanguage="zh-CN">
        </TextSettings>
    </LayoutSettings>
    <RootTable DataKeyField="Row_ID">
        <Columns>
            <ISWebGrid:WebGridColumn Name="RowNumber" Caption="RowNumber" Width="40px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn AllowGrouping="No" AllowSizing="No" AllowSorting="No" Bound="False" ColumnType="CheckBox" EditType="NoEdit" IsRowChecker="True" Name="colChk" ShowInSelectColumns="No" Width="25px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="BeiZhu" Caption="BeiZhu" DataMember="BeiZhu" Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="TargetDispName" Caption="TargetDispName" DataMember="TargetDispName"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="FromDispName" Caption="FromDispName" DataMember="FromDispName"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="GenerateDate" Caption="GenerateDate" DataMember="GenerateDate"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="Edit" Caption="View" ColumnType="Template" Width="35px"
                IsAutoWidth="false">
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
                <CellTemplate>
                    <a href='javascript:window.showModalDialog("Detail.aspx?Row_ID=<%#DataBinder.Eval(Container.DataItem,"Row_ID")%>")'>
                        <img src='bigview.gif' border='0'></a>
                </CellTemplate>
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="Enter" Caption="Delete" ColumnType="Template" Width="40px">
                <FooterStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center" Width="40px">
                </CellStyle>
                <CellTemplate>
                    <img src='Delete.gif' style="cursor: hand;" onclick="deleteOnePW('<%#DataBinder.Eval(Container.DataItem,"Row_ID")%>','<%#DataBinder.Eval(Container.DataItem,"BeiZhu")%>');" />
                </CellTemplate>
            </ISWebGrid:WebGridColumn>
        </Columns>
    </RootTable>
</ISWebGrid:WebGrid>
<script>
        function deleteOnePW(rowGuid, BeiZhu) {
            document.getElementById("<%= TxtPingWei.ClientID %>").value = rowGuid;
            document.getElementById("<%= TxtBeiZhu.ClientID %>").value = BeiZhu;
            document.getElementById("<%= DelDangQian.ClientID %>").click();
        }
       
</script>

 the details of the problem are as follows,
when I click Delete Image and it will show "Index was outside the bounds of the array" error.

However, we change the 'Delete' image's template to

<img src='Delete.gif' style="cursor: hand;" onclick="deleteOnePW('<%#DataBinder.Eval(Container.DataItem,"Row_ID")%>');" />

it will be all right.Should the "deleteOnePW" function only have one parameter?However, when I delete the "View" Column , it will be all right.(this issue does not occur)

<ISWebGrid:WebGrid ID="GridHandle" runat="server" Width="99%" OnInitializeRow="WebGrid1_InitializeRow"
    UseDefaultStyle="True" DataSourceID="ISDataSource1" DataMember="Messages_Center">
    <LayoutSettings AllowSorting="No" AutoFitColumns="true" PagingLoadMode="Custom" AllowGrouping="No" PagingMode="ClassicPaging" PagingSize="20">
        <TextSettings Language="UseCustom" UseLanguage="zh-CN">
        </TextSettings>
    </LayoutSettings>
    <RootTable DataKeyField="Row_ID">
        <Columns>
            <ISWebGrid:WebGridColumn Name="RowNumber" Caption="RowNumber" Width="40px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn AllowGrouping="No" AllowSizing="No" AllowSorting="No" Bound="False" ColumnType="CheckBox" EditType="NoEdit" IsRowChecker="True" Name="colChk" ShowInSelectColumns="No" Width="25px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="BeiZhu" Caption="BeiZhu" DataMember="BeiZhu" Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="TargetDispName" Caption="TargetDispName" DataMember="TargetDispName"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="FromDispName" Caption="FromDispName" DataMember="FromDispName"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="GenerateDate" Caption="GenerateDate" DataMember="GenerateDate"
                Width="150px">
            </ISWebGrid:WebGridColumn>
            <ISWebGrid:WebGridColumn Name="Enter" Caption="Delete" ColumnType="Template" Width="40px">
                <FooterStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center" Width="40px">
                </CellStyle>
                <CellTemplate>
                    <img src='Delete.gif' style="cursor: hand;" onclick="deleteOnePW('<%#DataBinder.Eval(Container.DataItem,"Row_ID")%>','<%#DataBinder.Eval(Container.DataItem,"BeiZhu")%>');" />
                </CellTemplate>
            </ISWebGrid:WebGridColumn>
        </Columns>
    </RootTable>
</ISWebGrid:WebGrid>

Do you have any idea on what is causing this behaviour ?We need to fix this soon, kindly help

Thanks

All times are GMT -5. The time now is 11:33 AM.
Previous Next