Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3307754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:26:34+00:00 2026-05-17T21:26:34+00:00

i have the following problem concerning the index:: my source code:: <table style=width: 80%>

  • 0

i have the following problem concerning the index::

my source code::

<table style="width: 80%">
        <tr>
            <td>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <img src ="images/addNews_photo.jpg" width ="70px" 
    height ="70px" /><asp:Label ID="lbl_title" runat="server" CssClass="subtitle"></asp:Label><br />
                    <asp:HiddenField ID="hf_unitId" runat="server" />
                    <br />
                    <asp:Label ID="lbl_newsDate" runat="server"></asp:Label>
                    <br />
                    <asp:Image ID="img_news" runat="server" BorderWidth="4px" Height="400px" 
                        Width="669px" />
                    <br />
                    <br />
                    <asp:Label ID="txt_desc" runat="server" BorderStyle="None" BorderWidth="0px" 
                        Width="796px"></asp:Label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="lv_news" EventName="ItemCommand" />
                </Triggers>
                </asp:UpdatePanel>
               &nbsp;&nbsp;<br />
                <asp:Label ID="Label1" runat="server" CssClass="subtitle" Text="More News:"></asp:Label>
                <br />`
                            <hr class="Alternating" 

                                style="width: 560px; text-align: left; background-color: #008000; height: 1px;" 
                                __designer:mapid="3c5" />
                                <br />
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                    <asp:ListView ID="lv_news" runat="server" ItemPlaceholderID="a" 
                    DataSourceID="ObjectDataSource1" onitemcommand="lv_news_ItemCommand" 
                    DataKeyNames="newsId" onitemdatabound="lv_news_ItemDataBound">
                                        <LayoutTemplate>
                                            <table ID="Table1" runat="server" cellpadding="2" cellspacing="2" 
                                                 class="Alternating" >
                                                <tr ID="a" runat="server">
                                                </tr>
                                            </table>
                                        </LayoutTemplate>
                                        <ItemTemplate>
                                            <tr ID="Tr1" runat="server">
                                                <td>
                                                    <asp:HiddenField id = "hf_newsId" runat ="server" 
                                                        Value = '<%#Eval("newsId")%>' />
                                                    <asp:Label ID="Label2" runat="server" Text="*" Font-Bold="True"></asp:Label>
                                                    &nbsp;
                                                    <asp:LinkButton ID="lbtn_link" runat="server" 
                                                             Text ='<%#Eval("englishNewsTitle")%>' 
                                                             CommandArgument ='<%# Container.DataItemIndex%>' 
                                                        CommandName ="others"> </asp:LinkButton>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:ListView>
                                    <asp:DataPager ID="DataPager1" runat="server" 
                                        onprerender="DataPager1_PreRender" PagedControlID="lv_news" PageSize="1">
                                        <Fields>
                                            <asp:NextPreviousPagerField />
                                        </Fields>
                                    </asp:DataPager>
                                    <br />
                                </ContentTemplate>
                </asp:UpdatePanel>

                <br />
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                    SelectMethod="GetAllNewsEnabled" TypeName="Managers.News">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hf_unitId" Name="FK_UnitId" 
                            PropertyName="Value" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>

                <br />

            </td>
        </tr>
    </table>

the code behind ::

public partial class showNews : System.Web.UI.Page
{
    static int index;
    protected void Page_Load(object sender, EventArgs e)
    {
        Managers.News nn = new Managers.News();
        Managers.Photo p = new Managers.Photo();
        hf_unitId.Value = "1";

        if (!IsPostBack)
        {

                lbl_title.Text = nn.GetTheLatestNews(1).Rows[0][1].ToString();
                string newsId = nn.GetTheLatestNews(1).Rows[0][0].ToString();
                string photoName = p.GetAllPhotos(int.Parse(newsId)).Rows[0][2].ToString();
                string dir = "NewsImages" + "/" + "UnitNum" + "1" + "_" + "NewsNum" + newsId + "/";
                img_news.ImageUrl = dir + photoName;
                lbl_newsDate.Text = nn.GetTheLatestNews(1).Rows[0][9].ToString();
                txt_desc.Text = nn.GetTheLatestNews(1).Rows[0][5].ToString();

        }
    }
    /* =========================================================================== */
    protected void lv_news_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        Managers.News nn = new Managers.News();
        Managers.Photo p = new Managers.Photo();
        index = Convert.ToInt32(e.CommandArgument);


        if (e.CommandName == "others")
        {
            int newsId = int.Parse(((HiddenField)lv_news.Items[index].FindControl("hf_newsId")).Value);
            lbl_title.Text = nn.GetNewsInList(newsId)[0].EnglishNewsTitle;
            string photoName = p.GetAllPhotos(newsId).Rows[0][2].ToString();
            string dir = "NewsImages" + "/" + "UnitNum" + "1" + "_" + "NewsNum" + newsId + "/";
            img_news.ImageUrl = dir + photoName;
            lbl_newsDate.Text = nn.GetNewsInList(newsId)[0].ShowingDate;
            txt_desc.Text = nn.GetNewsInList(newsId)[0].EnglishText;

        }
    }
    protected void DataPager1_PreRender(object sender, EventArgs e)
    {

        lv_news.DataBind();
    }

the problem is appeared when i have added the pager to my list view ,,i have out of range for index exception …
how to determine the page iam in and specify the right index either i use list view or grid view or other such controls..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:26:35+00:00Added an answer on May 17, 2026 at 9:26 pm

    Finally i fix my problem.

    The problem is in the following line::

    CommandArgument ='<%# Container.DataItemIndex%>'


    the command argument not reset itself every time when move from page to another page..

    • The answer is ::(in the case of
      ListView):

    CommandArgument ='<%# ((ListViewDataItem)Container).DisplayIndex%>'


    • The answer is :: (in the case of
      GridView):

    CommandArgument='<%#((GridViewRow)Container).RowIndex%>'


    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following problem since the server has safe mode turned on,
I have the following code in my .htaccess: RewriteEngine On RewriteBase / RewriteRule ^index\.php$
I have been using the following code for months (without problem) in a .NET
i have following problem To decode the Biquinary code use the number 5043210. At
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {
I have the following problem in my Data Structures and Problem Solving using Java
I have the following problem: I open the dialog, open the SIP keyboard to
I have the following problem. If I query values with a keyfigure which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.