问题描述
亲爱的所有人
任何身体都举个例子
如何使用编码
Dear All
any body give example
how can populate datalist with the coding
推荐答案
<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'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
这篇关于数据列表填充示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!