GridView中的多个参数,其中多个DataKeyNames为所有参数传递相同的值

时间:2013-08-26 14:56:46

标签: c# asp.net .net gridview

我有一个gridview1,我想填充Gridview2

Gridview1的声明如下:

<asp:GridView runat="server" ID="gwDup" AllowPaging="True" AllowSorting="True" PageSize="15" DataKeyNames="CASEID, Column2, ADATE, adddate"     AutoGenerateColumns="False" DataSourceID="SqlDataSource1"` >
 <asp:CommandField ShowSelectButton="True" />

    <asp:BoundField DataField="Column1" HeaderText="Possible Duplicates" ReadOnly="True" 
        SortExpression="Column1" />
    <asp:BoundField DataField="CASEID" HeaderText="CASEID" 
        SortExpression="CASEID" />
    <asp:BoundField DataField="Column2" HeaderText="Column2"            SortExpression="Column2" />
    <asp:BoundField DataField="ADATE" HeaderText="ADATE" SortExpression="ADATE" />
    <asp:BoundField DataField="AddDate" HeaderText="AddDate" 
        SortExpression="AddDate" />
</Columns>
</asp:GridView>

我点击了一个函数来检查当我点击选择时传入的值:

protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        foreach (ControlParameter s in SqlDataSource2.SelectParameters)
        {
            Response.Write(s.ToString());
        }
    }

(我使用调试器获取值,而不是response.write ...)

虽然看起来参数名称应该改变,但值总是相同的(caseID,这是第一个参数)我在这里做错了吗?为什么所有4个参数都传递相同的值?

0 个答案:

没有答案