Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从asp.net中的数据库检索数据的超链接_C#_Html_Asp.net - Fatal编程技术网

C# 从asp.net中的数据库检索数据的超链接

C# 从asp.net中的数据库检索数据的超链接,c#,html,asp.net,C#,Html,Asp.net,我正在开发作业门户,它显示存储在SQL Server数据库中的不同作业。我正在使用ASP.NET和HTML </div> 我在数据库表中有作业标题和唯一的作业id。我已经为从数据库检索到的作业标题创建了超链接。现在,我想通过单击该作业的作业标题,在不同的页面上显示该作业的详细信息 </div> 我需要特定作业的作业id,我想在下一个超链接页面上显示其详细信息。不使用job_title而不是job_id的原因是job_title不是唯一的,但job_id是唯一的

我正在开发作业门户,它显示存储在SQL Server数据库中的不同作业。我正在使用ASP.NET和HTML

  </div>
我在数据库表中有作业标题和唯一的作业id。我已经为从数据库检索到的作业标题创建了超链接。现在,我想通过单击该作业的作业标题,在不同的页面上显示该作业的详细信息

  </div>
我需要特定作业的作业id,我想在下一个超链接页面上显示其详细信息。不使用job_title而不是job_id的原因是job_title不是唯一的,但job_id是唯一的。请告诉我如何做到这一点,或者您是否有其他解决方案

  </div>
下面是一些示例代码:

  </div>
jobs.aspx

      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JobPortalConnectionString2 %>" SelectCommand="SELECT [job_title], [description] FROM [jobs]"></asp:SqlDataSource>
      <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
          <AlternatingItemTemplate>
              <strong>Job Title:</strong>
              <span style="">
              <asp:Label ID="job_titleLabel" runat="server" Text='<%# Eval("job_title") %>' />
              <br />
              <strong>Description:</strong>
              <asp:Label ID="descriptionLabel" runat="server" Text='<%# Eval("description") %>' />
              <br />
              <br />
              </span>
          </AlternatingItemTemplate>
          <EditItemTemplate>
              <span style="">job_title:
              <asp:TextBox ID="job_titleTextBox" runat="server" Text='<%# Bind("job_title") %>' />
              <br />
              description:
              <asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("description") %>' />
              <br />
              <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
              <br /><br /></span>
          </EditItemTemplate>
          <EmptyDataTemplate>
              <span>No data was returned.</span>
          </EmptyDataTemplate>
          <InsertItemTemplate>
              <span style="">job_title:
              <asp:TextBox ID="job_titleTextBox" runat="server" Text='<%# Bind("job_title") %>' />
              <br />description:
              <asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("description") %>' />
              <br />
              <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
              <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
              <br /><br /></span>
          </InsertItemTemplate>
          <ItemTemplate>
              <strong>Job Title:</strong>
              <span style="">
              <asp:Label ID="job_titleLabel" runat="server" Text='<%# Eval("job_title") %>'></asp:Label>
              <br />
              <strong>Description:</strong>
              <asp:Label ID="descriptionLabel" runat="server" Text='<%# Eval("description") %>'></asp:Label>
              <br />  
              <br/>
              </span>
          </ItemTemplate>
          <LayoutTemplate>
              <div id="itemPlaceholderContainer" runat="server" style="">
                  <span runat="server" id="itemPlaceholder" />
                  &nbsp;</span></div>
              <asp:Button ID="Button1" runat="server" Height="30px" OnClick="Button1_Click1" Text="Apply Now" Width="100px" />
              <div style="">
                  <asp:DataPager ID="DataPager1" runat="server">
                      <Fields>
                          <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                          <asp:NumericPagerField />
                          <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                      </Fields>
                  </asp:DataPager>
              </div>
          </LayoutTemplate>
          <SelectedItemTemplate>
              <span style="">job_title:
              <asp:Label ID="job_titleLabel" runat="server" Text='<%# Eval("job_title") %>' />
              <br />
              description:
              <asp:Label ID="descriptionLabel" runat="server" Text='<%# Eval("description") %>' />
              <br />
  </div>

  </div>

看起来您希望有如下URL:

  </div>
blabla-your-website.com/fisrt-job-title
blabla-your-website.com/second-job-title
blabla-your-website.com/other-job-title
但是你说:

  </div>
作业标题不是唯一的,但作业id是唯一的

  </div>
所以这是不可能的。常见的解决方案是在url中同时使用ID和标题:

  </div>
blabla-your-website.com/1-fisrt-job-title
blabla-your-website.com/22-second-job-title
blabla-your-website.com/333-other-job-title
其中1、22和333是特定作业的唯一ID

  </div>
如果你的标题是独一无二的,那就很容易做到。看一看。它用于将标题转换为URL,如RacoonBlog测试中的以下代码:

  </div>
        var result = SlugConverter.TitleToSlug("Document based modeling: Auctions & Bids");
        Assert.Equal("document-based-modeling-auctions-bids", result);

        result = SlugConverter.TitleToSlug("Hiring Questions–The phone book");
        Assert.Equal("hiring-questions-the-phone-book", result);

最好显示一些示例代码。真的不确定您是否需要SQL、ASP.Net方面的帮助?我已经添加了.aspx页面的代码,请检查。。。。