日期:2014-05-18  浏览次数:20486 次

请教js给gridview中textbox赋值的问题
请教 我目前是一个动态自增行的gridview,第一列是一个textbox和一个linkbutton 
点击linkbutton弹出一个窗口选择姓名,然后把所选的姓名返回到 textbox中 
可是前台js无法给gridview中的textbox赋值 找不到textbox控件 

部分代码如下
HTML code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" BackColor="#4D77B1" BorderColor="#4D77B1" BorderStyle="None"
    BorderWidth="1px" CellPadding="3" CellSpacing="1" GridLines="None" PageSize="12"
    Style="font-size: 12px" Width="100%" OnPreRender="GridView1_PreRender" 
        onrowdatabound="GridView1_RowDataBound" >
    <PagerSettings Visible="False" />
    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
    <Columns>
            <asp:TemplateField HeaderText="参会人员">
            <ItemTemplate><asp:TextBox ID="Realname" runat="server"  Width="70%" Height="26px"></asp:TextBox><A href="javascript:void(0)"><IMG onclick="openuser1();" alt="" src=
            "../images/FDJ.gif" border="0"></A>
            <%--<asp:DropDownList runat="server" ID="Realname" DataSourceID="SqlDataSource1" 
                    DataTextField="Realname" DataValueField="Username" Width="98%" 
                    onselectedindexchanged="Realname_SelectedIndexChanged" >
            <asp:ListItem>——请选择——</asp:ListItem>
            </asp:DropDownList>
       
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:qpoaConnectionString6 %>" 
                    SelectCommand="SELECT [Username], [Realname] FROM [qp_username]"></asp:SqlDataSource>--%>
       
            </ItemTemplate>
            <ItemStyle Width="150px" Wrap="False" HorizontalAlign="Center" />
        </asp:TemplateField>
                                            
                                            
                                            
          <asp:TemplateField HeaderText="负责工作">
            <ItemTemplate>
            <asp:DropDownList runat="server" ID="mettingSX" DataSourceID="SqlDataSource2" 
                    DataTextField="mettingSX" DataValueField="mettingSX" Width="98%">
            <asp:ListItem Value="——请选择——">——请选择——</asp:ListItem>
            </asp:DropDownList>
       
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:qpoaConnectionString7 %>" 
                    SelectCommand="SELECT [mettingSX] FROM [mettingAP]"></asp:SqlDataSource>
       
            </ItemTemplate>
            <ItemStyle Width="450px" Wrap="False" HorizontalAlign="Center" />
        </asp:TemplateField>
                                        
        <asp:TemplateField HeaderText="完成时限">
            <ItemTemplate>
            <asp:TextBox ID="endtime" Width="100%" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.endtime") %>'
                    onclick="setDayHM(this);"></asp:TextBox>
            </ItemTemplate>