如何提供datagridview值的链接

如何提供datagridview值的链接

本文介绍了如何提供datagridview值的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0 && comboBox2.SelectedIndex == 9)
            {
                SqlCommand cm1 = new SqlCommand("select * from traintime", con);
                DataTable dth = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cm1);
                da.Fill(dth);
                dataGridView2.DataSource = dth;
            }
            else if (comboBox1.SelectedIndex == 0 && comboBox2.SelectedIndex == 2)
            {
                SqlCommand cm1 = new SqlCommand("select * from traintime where TrainNo=11026", con);
                DataTable dth = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cm1);
                da.Fill(dth);
                dataGridView2.DataSource = dth;
            }

推荐答案

Use gridview like this, in place of label you can use link button.....


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id1" DataSourceID="ObjectDataSource1">
<Columns>
        <asp:TemplateField HeaderText="Name" SortExpression="FirstName">
           <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
            </ItemTemplate>
          </asp:TemplateField>
    </asp:TemplateField>
</Columns>
</asp:GridView>


这篇关于如何提供datagridview值的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 06:54