嘿伙计们,我制作了一个中继器,显示员工 ID 和他在特定月份的休假。现在我的中继器工作正常。只是我想将用户在文本框中输入的 empID 显示为转发器标题。我的中继器代码是
> <table class="table1" >
> <asp:Repeater ID="Repeater1" runat="server">
> <HeaderTemplate>
> <tr>
> <td>EmpID</td>
> </HeaderTemplate>
> <ItemTemplate>
> <td><asp:Label ID="lblmonths" runat="server" Text='<%# Eval("Monthnames") %>' ></asp:Label></td>
> </ItemTemplate>
> <FooterTemplate>
> </tr>
> </FooterTemplate>
</asp:Repeater>
> <asp:Repeater ID="Repeater2" runat="server" >
> <HeaderTemplate>
> <tr>
> <td><asp:Label ID="empID" runat="server" Text='<%# Eval("EmpID") %>' ></asp:Label></td>
> </HeaderTemplate>
> <ItemTemplate>
> <td><asp:Label ID="leave" runat="server" Text='<%# Eval("Leaves") %>' ></asp:Label></td>
> </ItemTemplate>
> <FooterTemplate>
> </tr>
> </FooterTemplate>
> </asp:Repeater>
>
>
> </table>
而我背后的代码是
string cmdText3 = "select count(*) as Leaves from attendance where empid = '" + empID.Value + "' and extract(month from LeaveDate) between 1 and 6 group by extract(month from LeaveDate)";
MySqlCommand cmd3 = new MySqlCommand(cmdText3, cnx);
MySqlDataAdapter adapter3 = new MySqlDataAdapter();
DataSet ds3 = new DataSet();
adapter3.SelectCommand = cmd3;
adapter3.Fill(ds3);
DataTable dt3 = ds3.Tables[0];
Repeater2.DataSource = dt3;
Repeater2.DataBind();
这里显示 6 个月。现在此代码工作正常,但 EmpID 未显示。你能告诉我如何在这个标签的文本框中显示 empID 吗(<asp:Label ID="empID" runat="server" Text='<%# Eval("EmpID") %>' ></asp:Label>)
?我不熟悉后面代码中显示的数据表。可能在那里添加一列会有所帮助。我试过但什么也没发生。你能帮我解决这个问题吗?