小编Alw*_*ice的帖子

如何将DataSet转换为DataTable

我正在从SQL表中检索数据,因此我可以在页面上将结果显示为HTML表.稍后我需要能够将该表保存为CSV文件.

到目前为止,我已经找到了如何检索数据并将其填充到数据集中以供显示目的(这完美地工作)......

        string selectQuery = "SELECT Name, ProductNumber, ListPrice FROM Poduction.Product";

        // Establish the connection to the SQL database 
        SqlConnection conn = ConnectionManager.GetConnection();
        conn.Open();

        // Connect to the SQL database using the above query to get all the data from table.
        SqlDataAdapter myCommand = new SqlDataAdapter(selectQuery, conn);

        // Create and fill a DataSet.
        DataSet ds = new DataSet();
        myCommand.Fill(ds);
Run Code Online (Sandbox Code Playgroud)

以及如何使用以下代码将其保存在CSV文件中:http://www.evontech.com/login/topic/1983.html

    private void exportDataTableToCsv(DataTable formattedDataTable, string filename)
    {
       DataTable toExcel = formattedDataTable.Copy();
       HttpContext context = HttpContext.Current;
       context.Response.Clear();

       foreach …
Run Code Online (Sandbox Code Playgroud)

html c# sql asp.net

37
推荐指数
2
解决办法
23万
查看次数

一个表单,一个提交按钮,但两个动作

我有一个表单收集客户的信息然后它

  • 将它们保存在数据库中
  • 发几封电子邮件
  • 将信息发送到SalesForce(SF)部门

现在,前两个任务很简单,但第三个任务给我带来了麻烦.对于SF我没有做任何特别的事情,只需要添加他们的网址,他们将从表单中提取他们需要的所有必要信息.对我来说,似乎为了做这些我需要表单有2个动作与一个提交按钮相关(不能有2个表格或2个按钮).

所以在我的raf.php文件中我有这个表单,提交后我必须将它们重定向到raf-submitted.php显示成功/错误消息和其他必要信息的页面.

表格 (从这里得到了想法)

 <form id="referralForm" name="referralForm" autocomplete="off" enctype="multipart/form-data" method="POST">

 <input id="saveForm" name="saveForm" class="field-submit" type="button" value="Submit" style="padding-left:20px" width="100" tabindex="23" onclick="FormSubmission(); SalesForceSubmission();" />

 </form>
Run Code Online (Sandbox Code Playgroud)

JavaScript:

 $(document).ready(function()
 { 
    function SalesForceSubmission()
    {
       document.referralForm.action = "https://someAddress.salesforce.com/";
       document.referralForm.submit();          
       return true;
    }

    function FormSubmission()
    {
       document.referralForm.action = "raf-submitted.php";
       document.referralForm.submit();          
       return true;
    }
  });
Run Code Online (Sandbox Code Playgroud)

raf-submitted.php文件负责表单验证,数据库插入和电子邮件问题.

它不起作用.我也试过这些没有运气:

有人可以帮帮我吗?谢谢!

html javascript php forms action

6
推荐指数
1
解决办法
5万
查看次数

如何使用C#代码将onClick事件用于Hyperlink?

我正在尝试为我的页面中的超链接添加条件.

而不是只使用像这样的特定链接:<a href="help/Tutorial.html">Tutorial</a>我想为不同的用户显示不同的页面.例如,如果用户以管理员身份登录,则会向他们显示与常规用户不同的链接.

我修改了我的超链接: <a onclick="displayTutorial_Click">Tutorial</a>

并添加了此代码:

    protected void displayTutorial_Click(object sender, EventArgs e)
    {
        // figure out user information
        userinfo = (UserInfo)Session["UserInfo"];

        if (userinfo.user == "Admin")

            System.Diagnostics.Process.Start("help/AdminTutorial.html");

        else

            System.Diagnostics.Process.Start("help/UserTutorial.html");            
    }
Run Code Online (Sandbox Code Playgroud)

但这没效果.谁能帮助我弄清楚如何使Tutorial链接正常工作?非常感谢你提前!!!

c# asp.net

4
推荐指数
2
解决办法
11万
查看次数

在浏览器中查看电子邮件并转发给朋友

我正在创建一个HTML电子邮件,在电子邮件的顶部我想添加"在浏览器中查看"链接.我怎样才能做到这一点?在我使用MailChimp之前,他们有这个内置功能,可以自动生成我的电子邮件在线版本的链接.但我不想再使用MailChimp了,也不确定如何自己生成/收集链接.另外,我想添加一个转发给朋友按钮.这两个怎么办?

html email

2
推荐指数
1
解决办法
2万
查看次数

为什么我不能动态地向HTML表添加行?

到目前为止,我已经阅读了很多文章,并尝试了很多不同的方法来动态地向我的HTML表添加行,但没有任何工作.当我单击添加按钮[+]时,它不会添加一行.出于某种原因,当我这样做时,看起来它不会让我添加细胞:newCell = newRow.insertCell().我的newRow变量找不到insertCell()方法.

这是我的表:

<table ID="newDataTable" runat="server" width="400">
<tr runat="server"> 
    <td runat="server" nowrap="nowrap" bordercolor="#FFFFFF" width= "50">
        <label style="font-size:smaller"> CITY: </label>
    </td>
    <td runat="server" nowrap="nowrap" bordercolor="#FFFFFF" width= "80">
        <input id= "City_box" type="text" name="tb_CITY"/>
    </td>
    <td runat="server" nowrap="nowrap" bordercolor="#FFFFFF" width= "75">
        <label style="font-size:smaller"> &nbsp;&nbsp;&nbsp;STATE: </label>
    </td>
    <td runat="server" nowrap="nowrap" bordercolor="#FFFFFF" width= "90">
        <input id= "State_box" type="text" name="tb_STATE"/>
    </td>
    <td runat="server" align="left" bordercolor="#FFFFFF" width= "10">
        <input title="Add Row" id="addButton" type="button" value=" + " onclick="addRow()" />
    </td> 
    <td …
Run Code Online (Sandbox Code Playgroud)

html javascript asp.net html-table dynamic

2
推荐指数
1
解决办法
1997
查看次数

标签 统计

html ×4

asp.net ×3

c# ×2

javascript ×2

action ×1

dynamic ×1

email ×1

forms ×1

html-table ×1

php ×1

sql ×1