Click here to Skip to main content
15,896,408 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 modules and in those 3 module I have 6 ppt in my database mean each module contain 2 ppt and in those 6 ppts i have 18 pic each ppt have 3 pic. path of the images are save in database.
Module PPT
1 a,b,c a1.jpeg,2.jpeg,3.jpeg
2 d,e,f
3 g,h,i

same with b-i three images in each ppt and 3 ppt in three modulea

what i want on my page is to when user select module from the dropdown list i can see ppt related to that module and when i click on first ppt i can view 3 images inside it as a slide show. how can i do that this is my code but in this i get all the images related to that module i want to show ppt folder first after selecting module and then when user click on that folder user can view slideshow.. just like slideshare.net


How can i do that

this is my code:

C#
<table><tr>
    <td class="style4">
        <asp:Label ID="lblModule" runat="server" Text="Module"></asp:Label>
    </td>
    <td class="style3"><asp:DropDownList ID="ddlModule" runat="server" 
            AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Module_Name" 
            DataValueField="ModuleId">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:WebGallery %>" 
            SelectCommand="SELECT [Module_Name], [ModuleId] FROM [Module_Master]">
        </asp:SqlDataSource>
    </td>
        <td class="style3">
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
                onclick="btnSubmit_Click" />
        </td>
        <td class="style5">
            <asp:Label ID="lblMsg" runat="server">
           </asp:Label>
        </td>
    </tr>
</table>

<asp:DataList ID="dlImages" runat="server" RepeatColumns="5" CellPadding="5">
<ItemTemplate>
<a id="imageLink" href='<%# Eval("Imageurl") %>' rel="lightbox[round]"  runat="server" >
<asp:Image ID="Image1" ImageUrl='<%# (string) FormatImagePath( (string) Eval("Imageurl"))%>' runat="server" Width="112" Height="84" />
</a> 
 
</a> 
</ItemTemplate>
<ItemStyle BorderColor="Brown" BorderStyle="dotted" BorderWidth="3px" HorizontalAlign="Center"
VerticalAlign="Bottom" />
</asp:DataList>


.aspx.cs page

C#
protected void Page_Load(object sender, EventArgs e)
    {
        bindgrid();
        //Load();
    }
    protected string FormatImagePath(string Imageurl)
    {
        if (Imageurl != null && Imageurl.Length > 0)
            return ("~/" + Imageurl);
        else return null;
    }
    // In this images are save under module and ppt into a folder which specify by us
    protected void bindgrid()
    {
        con.Open();
        //Query to get ImagesName and Description from database
        SqlCommand command = new SqlCommand("SELECT ModuleId,pptId,Imageurl from Image_Master where ModuleId='"+ddlModule.SelectedValue+"'", con);
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(command);
        da.Fill(ds);
        dlImages.DataSource = ds;
        dlImages.DataBind();
        con.Close();   
        con.Close();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        bindgrid();
    }


thanks in advance
Posted
Updated 27-Dec-13 3:42am
v3

1 solution

Not really sure if this will solve your problem but a couple of things that I would change are...

First...
In your .aspx page change the AutoPostBack attribute on your ddlModule DropDownList control to be false. Like this...
ASP.NET
<asp:DropDownList ID="ddlModule" runat="server" 
  AutoPostBack="False" DataSourceID="SqlDataSource1" DataTextField="Module_Name" 
  DataValueField="ModuleId">
</asp:DropDownList>

I don't believe you need the drop list's AutoPostBack attribute to be True as you are using a button click event to fire the post-back.

Second...
In your aspx.cs page's Page_Load routine, wrap the bindgrid() function in a condition that checks if the page is a post back and only call the method if the page has not been posted back. The reasoning is, you are going to call the bindgrid() function in your button's click event and you don't want the Page Load to call this function on post backs triggered by the button. So, change your Page_Load routine to be this...
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostBack != true)
    {
        bindgrid();
    }
}
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900