学习无止境!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

方法:

public GridViewRow GetCurrentRow(Object CtrlInCell)
        {
            Control Ctrl = (Control)CtrlInCell;
            int Count = 0;
            while ((Ctrl = Ctrl.Parent) != null && Count < 5)
            {
                if (Ctrl.GetType().Name.IndexOf("Cell") >= 0)
                {
                    return (GridViewRow)Ctrl.Parent;
                }
                Count++;
            }
            return null;
        }

 

HTML代码

 

<CommonCtrl:ExtGridView ID="GV1" runat="server" width="100%"  AutoGenerateColumns="False"  DataKeyNames="ItemType" OnRowDataBound="GV1_RowDataBound" >
                            <Columns>
                                <asp:BoundField DataField="ItemType" HeaderText="型">
                                <itemstyle HorizontalAlign="Left" verticalalign="Top" />
                                </asp:BoundField>
                               <asp:TemplateField HeaderText="">
                                    <itemtemplate>
                                        <CommonCtrl:ExtGridView id="GV2" runat="server" OnRowDataBound="GV2_RowDataBound" DataKeyNames="ID,ItemType" AutoGenerateColumns="False" width="100%" >
                                        <HeaderStyle BackColor="#D5FFBF"></HeaderStyle>
                                        <Columns>
                                        <asp:TemplateField HeaderText="5173">
                                            <ItemTemplate>
                                              <%# Eval("ItemName")%>                 
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Left" Width="150px"></ItemStyle>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText=""><ItemTemplate>
                                        <%# GetTKItemName(Eval("MapID"),Eval("ItemValue")) %>
                                        <asp:DropDownList id="ddl_TK" runat="server" DataValueField="ID" DataTextField="ItemName" ></asp:DropDownList>
                                        <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="绑定" CssClass="button" __designer:wfdid="w9"></asp:Button>
                                        <asp:TextBox id="_ItemName" runat="server" Text='<%# Eval("ItemValue") %>' CssClass="input" width="90px" __designer:wfdid="w10"></asp:TextBox>
                                        <asp:Button id="Button2" runat="server" Text="搜索" CssClass="button" __designer:wfdid="w11" OnClick="Button2_Click"></asp:Button>
                                        </ItemTemplate>

                                        <ItemStyle HorizontalAlign="Left"></ItemStyle>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="类型" Visible="False"><ItemTemplate>
                                              <asp:Label ID="lb_Type" runat="server" Text='<%# Eval("ItemType") %>'></asp:Label>
                                              <asp:Label ID="lb_ID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>        
                                               <asp:Label ID="taoka" runat="server" ></asp:Label>          
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Left"></ItemStyle>
                                        </asp:TemplateField>
                                        </Columns>
                                        </CommonCtrl:ExtGridView>
                                       
</itemtemplate>
                                <itemstyle HorizontalAlign="Left" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="type"  >
                                    <ItemTemplate>
                                        <asp:Label ID="lb_tktype" runat="server" Text='<%# Eval("tkItemType") %>'></asp:Label>
                                   
</ItemTemplate>
                                    <itemstyle verticalalign="Top" />
                                </asp:TemplateField>
                            </Columns>
                        </CommonCtrl:ExtGridView>

 

 

//GridVIew控件调用的方法

protected void Button1_Click(object sender, EventArgs e)
    {
        GridViewRow row = GetCurrentRow(sender);
        DropDownList ddl = (DropDownList)row.Cells[1].FindControl("ddl_TK");  //

        Label lb_ID = (Label)row.Cells[2].FindControl("lb_ID");               //

        if (ddl == null || lb_ID==null)  return;

        bool result= DBMng.ExeUpdate("T5UITempletDefine/update/Update", CommonFunctions.GetInitHashtable("ID", lb_ID.Text.Trim()), CommonFunctions.GetInitHashtable("MapID", ddl.SelectedValue))>0;
        if (result)
        {
            ClientMsgBox("绑定成功");
            BindGV1();
        }
    }

 

posted on 2010-11-04 11:28  钻石眼泪  阅读(1463)  评论(0编辑  收藏  举报