开发者

gridview edittemplate not showing content

开发者 https://www.devze.com 2022-12-16 00:39 出处:网络
I have grid view with three column name, rate, category I am also using ajax rate here and one dropdown within edittemplate which binded with sqldatasource.

I have grid view with three column name, rate, category

I am also using ajax rate here and one dropdown within edittemplate which binded with sqldatasource.

But when click on edit it is not showing the drop down.

Please help to sort out this problem.

Code is

<asp:gridview id="GVTweet" runat="server" allowpaging="True" allowsorting="True"
    autogeneratecolumns="False" gridlines="None" pagesize="15" width="700px" onselectedindexchanged="GVTweet_SelectedIndexChanged"
    onrowcancelingedit="GVTweet_RowCancelingEdit" onrowediting="GVTweet_RowEditing"
    onrowupdated="GVTweet_RowUpdated" onrowupdating="GVTweet_RowUpdating">
        <HeaderStyle />
        <AlternatingRowStyle Height="70px" />
        <RowStyle Height="70px" />
        <Columns>
            <asp:TemplateField HeaderImageUrl="~/images/twet1.png" HeaderText="Tweets" 
            ItemStyle-Height="70px">
            <ItemTemplate>
                <table border="0" cellpadding="0" cellspacing="0" width="auto">
                    <tr style="width:400px;">
                        <td align="left" style="height:70px;" valign="top">
                        <span class="box_imag">
                        <asp:Image ID="ScreenImage0" runat="server" height="50" 
                            ImageUrl='<%#DataBinder.Eval(Container.DataItem,"ImageUrl")%>' width="50" />
                        </span><span class="box_cont">
                        <asp:Label ID="lblId" runat="server" 
                            Text='<%#DataBinder.Eval(Container.DataItem, "id")%>' Visible="false">
                        </asp:Label>
                        <div>
                        <strong>
                            <a href="javascript:void(0)" 
                                onclick='setscreenname(&#039;<%#DataBinder.Eval(Container.DataItem, "ScreenName")%>&#039;)' 
                                rel="external">
                            <asp:Label ID="lblScreenName0" runat="server" 
                                Text='<%#DataBinder.Eval(Container.DataItem, "ScreenName")%>'></asp:Label>
                            </a>
                        </strong>
                        <asp:Label ID="lblText0" runat="server" 
                            Text='<%#DataBinder.Eval(Container.DataItem, "Text")%>'></asp:Label>
                        </div>
                        <div class="meta">
                            <asp:Label ID="lblDate0" runat="server" 
                            Text='<%#DataBinder.Eval(Container.DataItem, "Date")%>'></asp:Label>
                        </div>
                        </span>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderImageUrl="~/images/rate1.png" 
                HeaderStyle-CssClass="headerCss1" HeaderText="Rate(1-5)" 
                SortExpression="Rating" >
            <ItemTemplate>
                <table border="0" cellpadding="0" cellspacing="0" width="auto">
                    <tr style="width:150px;" valign="top" >
                        <td style="height:70px;">
                            <asp:UpdatePanel ID="updtpnlTweet0" runat="server">
                                <ContentTemplate>
                                    <cc1:Rating ID="rateTweet" runat="server" CurrentRating='<%# Bind("Rating") %>' 
                                        EmptyStarCssClass="empatyStarRating" FilledStarCssClass="filledStarRating" 
        开发者_如何学Python                                MaxRating="5" onchanged="rateTweet_Changed" StarCssClass="ratingStar" 
                                        WaitingStarCssClass="savedStarRating">
                                    </cc1:Rating>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderImageUrl="~/images/category1.png" 
                    HeaderStyle-CssClass="headerCss2" HeaderStyle-Width="148px" 
                    HeaderText="Categorize It" ItemStyle-CssClass="iteamHeader2">                                           
            <ItemTemplate>
                <table width="auto" border="0" cellspacing="0" cellpadding="0">
                    <tr align="center" valign="top" style="width:150px;" >
                        <td align="center" valign="top" style="height:70px; float:left;" >                            
                            <asp:Label ID="lblid1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CategoryName")%>' ></asp:Label>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>                                        
            <EditItemTemplate>
                <asp:DropDownList ID="ddldivcategory" runat="server" Width="100px" CssClass="dropdowntweet" 
                    DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryId" >
                                </asp:DropDownList>                   
           </EditItemTemplate>
           </asp:TemplateField>                                    
        <asp:CommandField ShowEditButton="True" />
    </Columns>
</asp:gridview>


Try declaring the DataKeyNames property on the gridview.

<asp:GridView ID="GVTweet" runat="server" DataKeyNames="PrimaryKeyName"...


use like this and change datasource is solved my problem


Try this

    protected void GVTweet_RowEditing(object sender, GridViewEditEventArgs e)
    {
            GVTweet.EditIndex = e.NewEditIndex;

            //Load Grid
    }

<asp:gridview id="GVTweet" runat="server" allowpaging="True" allowsorting="True"
autogeneratecolumns="False" gridlines="None" pagesize="15" width="700px"     onselectedindexchanged="GVTweet_SelectedIndexChanged"
onrowcancelingedit="GVTweet_RowCancelingEdit" onrowediting="GVTweet_RowEditing"
onrowupdated="GVTweet_RowUpdated" onrowupdating="GVTweet_RowUpdating">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号