DataGread技巧

DataGrad里添加按钮
<asp:TemplateField HeaderText="察看座位"> 
<ItemTemplate>  
    <asp:ImageButton ID="btnAddApp" runat="server" AlternateText="座位" CausesValidation="false"  CommandArgument='<%#Eval ("placeNo")+"|"+Eval("Hallno")+"|"+Eval("FeatureAPPNO")+ "|" +Eval("Appcode")%>'  CommandName="座位"ImageUrl="~/Include/Images/d2.gif" OnCommand="CartItem_Command" ToolTip="察看座位" />  
 </ItemTemplate> 
</asp:TemplateField> 

绑定的ropDownList
 private void BindDate(DataTable table, DataTable imgTable)
    {
        this.grdvMovie.DataSource = table;
        this.grdvMovie.DataBind();
        this.grdvMovie.FindControl("drpdSelectImg");
        for (int i = 0; i < this.grdvMovie.Rows.Count; i++)
        {
            DropDownList dpdImg = (DropDownList)this.grdvMovie.Rows[i].FindControl("drpdSelectImg");
            //ListItem[] _item;
               // = new ListItem("全部影院", placeString)
            string filmNo = Convert.ToString(this.grdvMovie.DataKeys[i]["FilmNo"]);
            DataRow[] imgRow = imgTable.Select("FilmNo='" + filmNo + "'");
            int rowLength = imgRow.Length;
            ListItem[] imgItm = new ListItem[rowLength];
            for (int j = 0; j < rowLength; j++)
            {//ListItem _item = new ListItem("全部影院", placeString);
                imgItm[j] = new ListItem(imgRow[j][1].ToString(),imgRow[j][2].ToString());
            }
            dpdImg.DataSource = imgItm;
            dpdImg.DataBind();
        }
    }









posted on 2008-01-27 12:44  online  阅读(278)  评论(0编辑  收藏  举报

导航