Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 10, 2012 04:54 AM by basheerkal
Member
436 Points
500 Posts
Apr 09, 2012 08:47 PM|LINK
i have managed to upload picture but saves in image folder and database
but how can i get that picture to show on profile page when user wants a picture on his or her profile page
Apr 09, 2012 09:49 PM|LINK
i have it saved succesully in database and image folder how do i get it to show on the user profile page
i have app code folder
images folder
loginhelper etc
Star
8731 Points
1681 Posts
Apr 09, 2012 10:27 PM|LINK
Hi
SELECT ImageName, ImagePath FROM YourProfileTable WHERE UserID=@UserID
You can use a repeater to display all info: Home url, Full name, Image, etc.
Apr 09, 2012 10:42 PM|LINK
this is what i have in my userprofile how would you do that?
SqlConnection sqlCon = new SqlConnection(ConnectionString); SqlCommand sqlCom = new SqlCommand("SELECT Count(Username) FROM tblUserProfile WHERE Username=@Username", sqlCon); sqlCom.CommandType = System.Data.CommandType.Text; sqlCom.Parameters.AddWithValue("@Username", Username);
Apr 09, 2012 10:47 PM|LINK
You know how to use a repeater and a SqlDataSource control?
Apr 09, 2012 10:48 PM|LINK
sorry should i say thats displayed in my App_code/LoginHELPER.CS
Apr 09, 2012 10:50 PM|LINK
not got a clue how to use reapeater etc i got all this created for me apart from image thing i did myself
unless you fancy copynpasteing my work or something
Apr 09, 2012 10:55 PM|LINK
basically i made a login and stuff like that but the coder guy created alot of folders which i dont know half of them
looks akward but i like his work what he done for me but images is a problem that im trying to add
10672 Points
2426 Posts
Apr 10, 2012 04:54 AM|LINK
Try a tutorial like this.
Assumed that in yourtable Username, Name and Path of the image are stored in "UsernameField". "NameField" and "ImagePathField" repectively.
Put a GridView in your aspx page within your form as shown below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" > <Columns> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <asp:Label ID="lbl1" runat="server" Text='<%# Bind("Namefiled") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Photo"> <ItemTemplate> <asp:Image ID="Image1" runat="server" ImageUrl= '<%# Bind("ImagePathField") %>'/> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
In your code behind add this code
public void getPhoto() { con = new SqlConnection(YourConnectionString); con.Open(); string CurrentUserName = User.Identity.Name string qry = "select * from YourTable Where usernamefield = '" + CurrentUserName + "'" ; SqlCommand cmd = new SqlCommand(qry, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridView1.DataSource = dt; GridView1.DataBind(); } con.Close(); } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { getPhoto(); } }
Run your page ..
Hope this will give you a basic idea about showing images in web pages based on logged in user
richkyrs
Member
436 Points
500 Posts
bit of help here
Apr 09, 2012 08:47 PM|LINK
i have managed to upload picture but saves in image folder and database
but how can i get that picture to show on profile page when user wants a picture on his or her profile page
richkyrs
Member
436 Points
500 Posts
Re: bit of help here
Apr 09, 2012 09:49 PM|LINK
i have it saved succesully in database and image folder how do i get it to show on the user profile page
i have app code folder
images folder
loginhelper etc
Primillo
Star
8731 Points
1681 Posts
Re: bit of help here
Apr 09, 2012 10:27 PM|LINK
Hi
You can use a repeater to display all info: Home url, Full name, Image, etc.
Primillo
http://www.facebook.com/programandopuntonet
richkyrs
Member
436 Points
500 Posts
Re: bit of help here
Apr 09, 2012 10:42 PM|LINK
this is what i have in my userprofile how would you do that?
SqlConnection sqlCon = new SqlConnection(ConnectionString);
SqlCommand sqlCom = new SqlCommand("SELECT Count(Username) FROM tblUserProfile WHERE Username=@Username", sqlCon);
sqlCom.CommandType = System.Data.CommandType.Text;
sqlCom.Parameters.AddWithValue("@Username", Username);
Primillo
Star
8731 Points
1681 Posts
Re: bit of help here
Apr 09, 2012 10:47 PM|LINK
You know how to use a repeater and a SqlDataSource control?
Primillo
http://www.facebook.com/programandopuntonet
richkyrs
Member
436 Points
500 Posts
Re: bit of help here
Apr 09, 2012 10:48 PM|LINK
sorry should i say thats displayed in my App_code/LoginHELPER.CS
SqlConnection sqlCon = new SqlConnection(ConnectionString);
SqlCommand sqlCom = new SqlCommand("SELECT Count(Username) FROM tblUserProfile WHERE Username=@Username", sqlCon);
sqlCom.CommandType = System.Data.CommandType.Text;
sqlCom.Parameters.AddWithValue("@Username", Username);
richkyrs
Member
436 Points
500 Posts
Re: bit of help here
Apr 09, 2012 10:50 PM|LINK
not got a clue how to use reapeater etc i got all this created for me apart from image thing i did myself
unless you fancy copynpasteing my work or something
richkyrs
Member
436 Points
500 Posts
Re: bit of help here
Apr 09, 2012 10:55 PM|LINK
basically i made a login and stuff like that but the coder guy created alot of folders which i dont know half of them
looks akward but i like his work what he done for me but images is a problem that im trying to add
basheerkal
Star
10672 Points
2426 Posts
Re: bit of help here
Apr 10, 2012 04:54 AM|LINK
Try a tutorial like this.
Assumed that in yourtable Username, Name and Path of the image are stored in "UsernameField". "NameField" and "ImagePathField" repectively.
Put a GridView in your aspx page within your form as shown below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" > <Columns> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <asp:Label ID="lbl1" runat="server" Text='<%# Bind("Namefiled") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Photo"> <ItemTemplate> <asp:Image ID="Image1" runat="server" ImageUrl= '<%# Bind("ImagePathField") %>'/> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>In your code behind add this code
public void getPhoto() { con = new SqlConnection(YourConnectionString); con.Open(); string CurrentUserName = User.Identity.Name string qry = "select * from YourTable Where usernamefield = '" + CurrentUserName + "'" ; SqlCommand cmd = new SqlCommand(qry, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridView1.DataSource = dt; GridView1.DataBind(); } con.Close(); } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { getPhoto(); } }Run your page ..
Hope this will give you a basic idea about showing images in web pages based on logged in user
(Talk less..Work more)