数据列表填充示例代码 [英] datalist populate example with the coding

查看:71
本文介绍了数据列表填充示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人
任何身体都举个例子
如何使用编码

Dear All
any body give example
how can populate datalist with the coding

推荐答案

Google破坏了您的住所?填充数据列表?您设置数据源并进行数据绑定.而已.最好在文章中而不是在论坛回复中说明设置外观的方法.
Google broken where you live ? You set the data source and you data bind. That''s it. Setting up how it looks etc, is best explained in an article, not a forum reply.


This W3School article might be able to help you.


<asp:DataList ID="DataLstEmployee" Width="100%" runat="server"

            Font-Names="Verdana" Font-Size="Small" ForeColor="#000099">
        <ItemTemplate>
        <table width="100%" border="1px">
        <tr>
        <td class="style9" style="width:25%">Employee Id:</td>
        <td style="width:25%"><%# DataBinder.Eval(Container.DataItem, "EmployeeId")%></td>
        <td class="style9" style="width:25%">EmployeeName:</td>
        <td style="width:25%"><%# DataBinder.Eval(Container.DataItem, "EmployeeName")%></td>
        </tr>
        <tr>
        <td class="style9" style="width:25%">Father&#39;s Name:</td>
        <td style="width:25%"><%# DataBinder.Eval(Container.DataItem, "Father")%></td>
        <td class="style9" style="width:25%">Actual DOB:</td>
        <td style="width:25%"><%# DataBinder.Eval(Container.DataItem, "Mother")%></td>
        </tr>
        </table>
        </ItemTemplate>
        </asp:DataList>





void bindDatalist()
{
SqlCommand cmd =新的SqlCommand(选择EmployeeId,EmployeeName,父亲,来自abc的母亲",骗局);
con.Open();
SqlDataReader dtr = cmd.ExecuteReader();

DataLstEmployee.Datatsource = dtr;
DataLstEmployee.DataBind();
con.Close();
}

在页面加载时绑定此功能





void bindDatalist()
{
SqlCommand cmd = new SqlCommand("select EmployeeId,EmployeeName,Father,Mother from abc", con);
con.Open();
SqlDataReader dtr = cmd.ExecuteReader();

DataLstEmployee.Datatsource = dtr;
DataLstEmployee.DataBind();
con.Close();
}

bind this function on page load


这篇关于数据列表填充示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆