DataGrid中如何给模板列赋值
//.aspx--代码:
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="<<" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text=">>" />
<br />
<asp:datagrid id="dtgDj" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="10" BorderWidth="1px"
BorderColor="#000099" BackColor="White" Width="100%" PageSize="3"
AllowPaging="True">
<ItemStyle HorizontalAlign="Center" BorderWidth="15px" BackColor="White" ForeColor="#330099"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" BackColor="#507CD1" ForeColor="#FFFFCC"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="选 择">
<ItemTemplate>
<asp:CheckBox ID="chk0" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="sgd_id" HeaderText="编 号"></asp:BoundColumn>
<asp:BoundColumn DataField="sgd_sqr" HeaderText="申购人"></asp:BoundColumn>
<asp:BoundColumn DataField="sgd_wpmc" HeaderText="申购物品"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="状态">
<ItemTemplate>
<asp:Label style="Z-INDEX: 0" id="lblzt" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<PagerStyle NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Center" ForeColor="#330099"
BackColor="#FFFFCC" Mode="NumericPages" Visible="False"></PagerStyle>
</asp:datagrid>
//.CS--绑定及分页代码-----------------------------------------
private void CheckBind()
{
string str = "";
str = "select * from zcsgd_t_v WHERE bmjl_tp='2' ";
DataSet ds = new DataSet();
ds = Info.Select(str, "zcsgd_t_v");
//if (ds.Tables[0].Rows.Count > 0)
//{
// Label lbl = new Label();
// for (int c = 0; c < ds.Tables[0].Rows.Count; c++)
// {
// lbl = (Label)this.dtgDj.Items[c].FindControl("lblzt");
// if (ds.Tables[0].Rows[c]["zhb_tp"].ToString() == "1")
// {
// if (ds.Tables[0].Rows[c]["sgd_stu"].ToString() == "0")//
// {
// lbl.Text = "等候审核";
// }
// else if (ds.Tables[0].Rows[c]["sgd_stu"].ToString() == "2")
// {
// lbl.Text = "&l