Click here to Skip to main content
15,881,742 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Developing Employee Portal - Database design question. Pin
biop.codeproject14-Nov-11 15:04
biop.codeproject14-Nov-11 15:04 
GeneralRe: Developing Employee Portal - Database design question. Pin
Sunil Kokkiligadda15-Nov-11 6:11
Sunil Kokkiligadda15-Nov-11 6:11 
GeneralRe: Developing Employee Portal - Database design question. Pin
biop.codeproject15-Nov-11 12:56
biop.codeproject15-Nov-11 12:56 
QuestionHow to protect a page requested only by an external tool or administrator? Pin
TRAORE cheickna13-Nov-11 6:40
TRAORE cheickna13-Nov-11 6:40 
AnswerRe: How to protect a page requested only by an external tool or administrator? Pin
thatraja13-Nov-11 8:40
professionalthatraja13-Nov-11 8:40 
QuestionListView and DataPager in Update Panel Pin
cowcow1234513-Nov-11 6:13
cowcow1234513-Nov-11 6:13 
AnswerRe: ListView and DataPager in Update Panel Pin
thatraja13-Nov-11 8:49
professionalthatraja13-Nov-11 8:49 
GeneralRe: ListView and DataPager in Update Panel Pin
cowcow1234514-Nov-11 1:11
cowcow1234514-Nov-11 1:11 
The code are here...
ASP.NET
         <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> 
         
        <asp:UpdatePanel ID="UpdatePanel1" Updatemode="Always" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
        <asp:ListView ID="ListView1" runat="server" 
            OnItemCommand="ListView1_OnItemCommand" GroupItemCount="1">
        <LayoutTemplate>
        <div style="border: solid 1px black">
        <table>
        <asp:PlaceHolder ID="groupPlaceHolder" runat="server"></asp:PlaceHolder>
        </table>
      
        </LayoutTemplate>
        <GroupTemplate>
        <div>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
        </div>
        </GroupTemplate>
        <ItemTemplate>
        <tr>
        <td>
        <asp:LinkButton ID="LinkButton1" CommandName="Delete_item"  CommandArgument='<%# Eval("entry_no") %>' runat="server" Text="Delete!" />
        </td>
           
        </tr>
        <tr>
         <td>Location: <%#Eval ("location") %></td>
        </tr>
        
        <tr>
        <td>Type:<%#Eval ("type") %><asp:ImageButton ID="ImageButton1" onClientClick = "Button1_onclick()" runat="server" ImageUrl="play.gif" CommandName="Listen" CommandArgument='<%#Eval("type") %>'/></td>
        
        </tr>
        
        <tr>
        <td>Further Description: <%#Eval ("further_description") %><asp:ImageButton ID="Play_btn" runat="server" ImageUrl="play.gif" CommandName="Listen" CommandArgument='<%#Eval("further_description") %>' OnClientClick="popup('popUpDiv')" /></td>
        </tr>

        <tr>
        <td><%# test_item_photo_name(Eval("items_photo_name").ToString()) %></td>
        </tr>

        <tr>
        <td><asp:Button runat="server" Text="Play Recordings" CommandName="Recordings" CommandArgument='<%#Eval("recordings") %>' ID="recordings_btn" Visible="True" />
        </tr>

        </ItemTemplate>
      
        </asp:ListView>
          <asp:DataPager ID="pg" PageSize="1" runat="server" OnPreRender="DataPager1_PreRender" PagedControlID="ListView1">

        <Fields>
        <asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
        <asp:NumericPagerField />
        <asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
        </Fields>
      
        </asp:DataPager>
        </ContentTemplate>

</asp:UpdatePanel>
       </div>
           </form>
</div>


Code behind:
C#
protected void DataPager1_PreRender(object sender, EventArgs e)
    {


        DataTable result = (DataTable)Session["result"];
        ListView1.DataSource = result;
        ListView1.DataBind();
    }
    protected void pg_PagerCommand(object sender, DataPagerCommandEventArgs e)
    {
        e.NewMaximumRows = e.Item.Pager.MaximumRows;
        switch (e.CommandName)
        {
            case "Previous":
                if (e.Item.Pager.StartRowIndex > 0)
                    e.NewStartRowIndex = e.Item.Pager.StartRowIndex - 1;
                break;
            case "Next":
                e.NewStartRowIndex = e.Item.Pager.StartRowIndex + 1;
                break;
        }
    }
    protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
    {
       
        DataPager dpBottom;

        dpBottom = ((ListView)sender).FindControl("pg") as DataPager;

        dpBottom.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);

        ListView1.DataBind();

        UpdatePanel1.Update();


    }
    protected void ListView1_OnItemCommand(object sender, ListViewCommandEventArgs e)
    {
        Label1.Visible = false;
        if (String.Compare(e.CommandName.ToString(), "Recordings") == 0)
        {
            if (String.Compare(e.CommandArgument.ToString(), "") == 0)
            {
                Label1.Visible = true;
                Label1.Text = "No recordings found.";
            }
            else
            {
                String path = Server.MapPath(".") + "\\" + login_hash + "\\others\\" + e.CommandArgument.ToString();
                Play(path);
            }
        }
        else
        {
            if (String.Compare(e.CommandName.ToString(), "Listen") == 0)
            {

                Speak(e.CommandArgument.ToString());
            }
            if (String.Compare(e.CommandName.ToString(), "Delete_item") == 0)
            {
                DataTable result = (DataTable)Session["result"];
                for (int i = 0; i < result.Rows.Count; i++)
                {
                    if (result.Rows[i]["entry_no"].ToString() == e.CommandArgument.ToString())
                    {
                        if (result.Rows[i]["recordings"].ToString() != "")
                        {
                            File.Delete(Server.MapPath(".") + "\\" + login_hash + "\\others\\" + result.Rows[i]["recordings"].ToString());
                        }
                        if (result.Rows[i]["items_photo_name"].ToString() != "")
                        {
                            File.Delete(Server.MapPath(".") + "\\" + login_hash + "\\images\\item_photo" + result.Rows[i]["items_photo_name"].ToString());
                        }
                        //result.Rows.Remove(result.Rows[i]);
                        DataList1_ItemCommand(sender, null);
                    }
                }
                try
                {
                    String query = "delete from items_location where entry_no = " + e.CommandArgument.ToString();
                    Database.OpenConnection();
                    Database.BeginTransaction();
                    Database.Update_Insert(query);
                    Database.CommitTransaction();
                    Database.CloseConnection();
                    ListView1.DataSource = result;
                    ListView1.DataBind();
                    Session.Remove("result");
                    Session["result"] = result;
                }
                catch (Exception ex)
                {
                    Database.RollBackTransaction();
                    Database.CloseConnection();
                }
            }
        }

    }

QuestionHide my flash in iframes Pin
benams13-Nov-11 1:04
benams13-Nov-11 1:04 
AnswerRe: Hide my flash in iframes Pin
Not Active13-Nov-11 3:19
mentorNot Active13-Nov-11 3:19 
AnswerRe: Hide my flash in iframes Pin
Dennis E White14-Nov-11 6:41
professionalDennis E White14-Nov-11 6:41 
QuestionHow to implement an asynchronous code? Pin
TRAORE cheickna12-Nov-11 13:04
TRAORE cheickna12-Nov-11 13:04 
AnswerRe: How to implement an asynchronous code? Pin
Not Active12-Nov-11 16:21
mentorNot Active12-Nov-11 16:21 
Questioncontrols in asp.net Pin
Member 821751712-Nov-11 5:33
Member 821751712-Nov-11 5:33 
AnswerRe: controls in asp.net Pin
Dennis E White12-Nov-11 18:55
professionalDennis E White12-Nov-11 18:55 
Questionweb controls Pin
sc steinhayse11-Nov-11 5:55
sc steinhayse11-Nov-11 5:55 
AnswerRe: web controls Pin
Not Active11-Nov-11 7:44
mentorNot Active11-Nov-11 7:44 
GeneralRe: web controls Pin
Dennis E White11-Nov-11 12:23
professionalDennis E White11-Nov-11 12:23 
Questionhow to generate id to every click on save button. Pin
raiskhanshab11-Nov-11 4:28
raiskhanshab11-Nov-11 4:28 
AnswerRe: how to generate id to every click on save button. Pin
Not Active11-Nov-11 5:21
mentorNot Active11-Nov-11 5:21 
QuestionHow to determine if any users are currently viewing website? Pin
Goalie3511-Nov-11 3:43
Goalie3511-Nov-11 3:43 
AnswerRe: How to determine if any users are currently viewing website? Pin
Dennis E White11-Nov-11 5:46
professionalDennis E White11-Nov-11 5:46 
GeneralRe: How to determine if any users are currently viewing website? Pin
Not Active11-Nov-11 7:35
mentorNot Active11-Nov-11 7:35 
GeneralRe: How to determine if any users are currently viewing website? Pin
Dennis E White11-Nov-11 12:36
professionalDennis E White11-Nov-11 12:36 
GeneralRe: How to determine if any users are currently viewing website? Pin
Not Active11-Nov-11 13:34
mentorNot Active11-Nov-11 13:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.