简体   繁体   English

在gridview中单击链接按钮不会在detailsview中显示详细信息

[英]clicking on link button in gridview does not show the details in detailsview

I have a grid view and a details view. 我有一个网格视图和一个详细信息视图。 In that grid view I have a link button column in the first column. 在该网格视图中,我在第一列中有一个链接按钮列。 When I click on the link button column it has to show the corresponding row values in the details view. 当我单击链接按钮列时,它必须在详细信息视图中显示相应的行值。 I am using separate data sources for details view and grid view. 我将单独的数据源用于详细信息视图和网格视图。

This is the grid view code: 这是网格视图代码:

<asp:GridView ID="GridView2" runat="server" 
    DataSourceID="SqlDataSourcegridview" Height="533px" Width="316px" 
    style="text-align: left" EnableCallBack="false" 
    AutoGenerateColumns="False" > 
    <Columns>
        <asp:TemplateField ShowHeader="false">
            <HeaderTemplate>    
                <asp:Label ID="lbl1" runat="server" Text="DCN"></asp:Label>
            </HeaderTemplate>

            <ItemTemplate>
            <asp:LinkButton ID="lnkname" runat="server" SortExpression="DCN"
                            Text='<%#Eval("DCN") %>' CausesValidation="false"
                            CommandName='<%#Eval("DCN")%>' OnClick = "Link_buttonClick">
                   linkbutton
            </asp:LinkButton>

            </ItemTemplate>
        </asp:TemplateField>                               
        <asp:BoundField DataField="priority" HeaderText="priority" 
                        SortExpression="priority" />
   </Columns>
</asp:GridView>

Datasource for gridview: gridview的数据源:

<asp:SqlDataSource ID="SqlDataSourcegridview" runat="server" 
                   ConnectionString="<%$ ConnectionStrings:ConnectDBString %>" 
                   SelectCommand="SELECT * FROM [MASTERETMTABLE] WHERE ([DCN] = @DCN)">
     <SelectParameters>
         <asp:Parameter DefaultValue="BAT" Name="DCN" Type="String" />
     </SelectParameters>
 </asp:SqlDataSource>

Details view: 详细信息视图:

<asp:Panel ID="paneldetails" runat="server" BackColor="#CCCCCC" 
           Visible="False" >
    <asp:DetailsView ID="detailsvw" runat="server" AutoGenerateRows="False" 
                     DataSourceID="SqlDataSourcedetailsview" Width="424px"> 
         <Fields>
             <asp:BoundField DataField="DCN" HeaderText="DCN" SortExpression="DCN" />
             <asp:BoundField DataField="PRIORITY" HeaderText="PRIORITY" 
                             SortExpression="PRIORITY" />
         </Fields
    </asp:DetailsView>
</asp:Panel>

and this is my datasource for details view 这是我的详细信息视图的数据源

<asp:SqlDataSource ID="SqlDataSourcedetailsview" runat="server" 
                   ConnectionString="<%$ ConnectionStrings:ConnectDBString %>" 
                   SelectCommand="SELECT * FROM [MASTERETMTABLE] WHERE ([DCN] = @DCN)">
    <SelectParameters>
        <asp:ControlParameter Name="DCN" ControlID="GridView2"/>
    </SelectParameters>
</asp:SqlDataSource>

This is the code behind file for the gridview page. 这是gridview页面文件的代码。

protected void Link_buttonClick(object sender, EventArgs e)
{
    paneldetails.Visible = true;
    detailsvw.Visible = true;
    // do I need to add any thing at here
}

I am not able to get the data into details view here. 我无法在此处将数据放入详细信息视图。 When I click on any cell in the first column it shows the details view in panel. 当我单击第一列中的任何单元格时,它将在面板中显示详细信息视图。

How do I get the details view to display the data from the clicked row? 如何获取详细信息视图以显示单击的行中的数据?

实现主从关系的简单方法是将DataKeyNames="DCN" (与您的情况有关)添加到第一个GridView并将其作为“详细信息”表单中的“参数”引用:请参见此处的示例: http:// www。 vkinfotek.com/detailsview/gridview-detailsview-master-detail-example.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在主细节GridView和DetailsView中隐藏和显示DetailsView? - How to hide and show the DetailsView in the Master-Details GridView & DetailsView? 如何在gridview中显示用户详细信息,其中第一个girdview包含链接按钮列表 - how to show details of user into gridview where 1st girdview contain list of link button 单击Gridview中的“选择”按钮时,查看详细信息(所有字段) - View Details (all the Fields) when clicking on Select Button in Gridview Gridview项目模板的列宽固定,并使用链接按钮查看详细信息 - Gridview item template column width fixed and View details with link Button 如何在DetailsView ItemTemplate中有条件地显示/隐藏链接 - how to conditionally show/hide link in DetailsView ItemTemplate detailsview不会在一页中显示所有数据 - detailsview does not show all data in one page 如何通过单击另一个gridview中的链接按钮在jquery对话框中显示Gridview - How to Display a Gridview inside jquery dialog by clicking a link button inside another gridview 单击以显示模式框时,在链接按钮上回发 - Postback on link button when clicking to show modal box 通过单击按钮折叠列表框中的详细信息 - Collapse details in listbox by clicking a button 在GridView和DetailsView中绑定相同的数据。 为什么我没有得到详细信息视图的输出? - Binding the same data in GridView and DetailsView. Why am I not getting output for Details View?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM