I'm use to setting up a photo in a List View or Grid View just using the wizards in Visual Studio. I was given a simple example of an Item template, which works well for what I'm doing, but I'm not sure how to display a photo with it. I have a folder in
my project with the photos in it. I store the path to the photos in my sql database. How do I display the photos with the other fields in my Item template? Here is the code I have so far:
<%# Eval("SodaName")%> Price Range:<%# Eval("PriceRange")%> |
<%# Eval("StoreName") %> |
.....and so on.
Add an Image control and bind its ImageUrl property to the database field that stores the path.
Use Image Control and bind ImageUrl Property.
If you saved filename only to SodaName, bind ImageUrl like this :
If you store the path like "~/images/filename.jpg" or "images/filename.jpg" use like this
Dont store the path like "c:\images\filename.jpg", store virtual path (url) instead.
Width="70px" Height="50px" />
in aspx.cs page
public string GetImageURL(string url)
{
string taxid = url;
taxid = "~/UploadedDocument/VehiclePhoto/" + url+".jpg" ;
return taxid;
}
When a pie chart slice represents a small amount, the label tends to touch or over write another slice's label.
In essence they are touching.
I know I can move the label outside of the pie chart, but I prefer them inside. Is there a way to scatter the labels so they don't butt up against each other?
Hi StrangerMike,
These are a number of possibilities for keeping your labels from overlapping:
- First try decreasing the font size, or increasing the size of your chart to allow more room for the labels.
- Pie and Doughnut charts have the ability to collect smaller slices into one, We have samples that show how this is done: in our samples environment, go to Gallery >> ChartTypes >> Pie and Doughnut Charts, and see "Collecting Small Pie Segments" and
"Supplemental Pie Charts" (in Windows Forms) or "Collecting Pie Slices" and "Pie Chart Small Segments" (in ASP.NET.)
- If the above options do not work, or you would prefer not to change your chart in those ways, set the Series custom attribute PieLabelStyle to "Outside", so that point labels are positioned outside of the pie/doughnut with connecting lines. Right-click
the Chart and choose Properties, open the properties for your series, and find the custom attributes. You can also use code like this:
[C#]
Chart1.Series[0]["PieLabelStyle"] = "Outside";
[VB.NET]
Chart1.Series(0)("PieLabelStyle") = "Outside";
However, you may still find that your labels overlap:
If your labels still overlap, you can spread them out by setting theChartArea's Area3DStyle.Enable3D property to True, and adjust theArea3DStyle.XAngle property to 0 or a low value to make the Chart look 2D. You can do this in the wizards, from our properties settings, or with code:
[C#]
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ChartAreas[0].Area3DStyle.XAngle = 10;
[VB.NET]
Chart1.ChartAreas(0).Area3DStyle.Enable3D = True
Chart1.ChartAreas(0).Area3DStyle.XAngle = 10
or else,
You can play around with following code:
Chart1.ChartAreas(0).AxisY.LabelStyle.TruncatedLabels = False
Chart1.ChartAreas(0).AxisX.LabelStyle.TruncatedLabels = False
Hope this helps.
Thanks,
Jatin
Glad Mike that I could help you.. 
When a pie chart slice represents a small amount, the label tends to touch or over write another slice's label.
In essence they are touching.
I know I can move the label outside of the pie chart, but I prefer them inside. Is there a way to scatter the labels so they don't butt up against each other?
Hi StrangerMike,
These are a number of possibilities for keeping your labels from overlapping:
- First try decreasing the font size, or increasing the size of your chart to allow more room for the labels.
- Pie and Doughnut charts have the ability to collect smaller slices into one, We have samples that show how this is done: in our samples environment, go to Gallery >> ChartTypes >> Pie and Doughnut Charts, and see "Collecting Small Pie Segments" and
"Supplemental Pie Charts" (in Windows Forms) or "Collecting Pie Slices" and "Pie Chart Small Segments" (in ASP.NET.)
- If the above options do not work, or you would prefer not to change your chart in those ways, set the Series custom attribute PieLabelStyle to "Outside", so that point labels are positioned outside of the pie/doughnut with connecting lines. Right-click
the Chart and choose Properties, open the properties for your series, and find the custom attributes. You can also use code like this:
[C#]
Chart1.Series[0]["PieLabelStyle"] = "Outside";
[VB.NET]
Chart1.Series(0)("PieLabelStyle") = "Outside";
However, you may still find that your labels overlap:
If your labels still overlap, you can spread them out by setting theChartArea's Area3DStyle.Enable3D property to True, and adjust theArea3DStyle.XAngle property to 0 or a low value to make the Chart look 2D. You can do this in the wizards, from our properties settings, or with code:
[C#]
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ChartAreas[0].Area3DStyle.XAngle = 10;
[VB.NET]
Chart1.ChartAreas(0).Area3DStyle.Enable3D = True
Chart1.ChartAreas(0).Area3DStyle.XAngle = 10
or else,
You can play around with following code:
Chart1.ChartAreas(0).AxisY.LabelStyle.TruncatedLabels = False
Chart1.ChartAreas(0).AxisX.LabelStyle.TruncatedLabels = False
Hope this helps.
Thanks,
Jatin
Glad Mike that I could help you.. 
I am using 3 tier first time the first thing i want to bind my dropdownlist with a sql table column.
I have in APPCODE BLL folder (empty) while in DAL two built in classess Sqlhelper.cs and DBBridge.cs.
App code
BLLempty
DAL
sqlhelper.cs
DBBridge.cs
while on presentation layer drop down list present.
so how can i bind my dropdownlist?
do i need to make a function in sqlhelper or DBBridge.cs or i need to make class then a function in BLL Folder??
or do i need to bind dropdown directly through wizard ?? which is absolutely not acceptable in professional programming..
Hi,
BLL contains business logic of your code, so what you need to do is:
1.Create a function in DAL to retrieve the data.
2. Create a function in BAL and apply any conditions or business logics if any. From BAL, you will call your DAL function and pass the parameters to BAL. From this BAL function return the data you get from DAL function to your page.
3. Just call the BAL function and bind the dropdown from the data returned from BAL.
This is already resolved by some one in asp.net forum
If i summarize your requirement, it would be something as follows:
1. A BusinessEntity (Employee, Student, Product) with simple properties
2. A BLL.ManagerClass which creates a of BusinessEntity (from step 1)
3. An ObjectDataSource within the WebPage (withe DLL) calls BLL.ManagerClass (from step 2) to get the
4. Set the DataSource of the DDL to the ObjectDataSource
5. Set the DataTextField and DataValueField of the DDL to the respective BusinessEntity fields
6. You have it without binding your table to the DDL
For further help, have a look at the following link:
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=420
Or Refer to below code.
//using 3 tier architecture BLLCommonTasks newCountries = new BLLCommonTasks(); DataTable dtCountry = PopulationOverview.BLL.BLLCommonTasks.getAllCountriesList(); ddlCountries.DataSource = dtCountry; ddlCountries.DataTextField = "country_name"; ddlCountries.DataValueField = "country_id"; ddlCountries.DataBind();
//BLL public static DataTable getAllCountriesList() { return DAL.commonTasks.getAllCountriesList(); }
//DAL public static DataTable getAllCountriesList() { bool status = false; DBCon sqlCon = new DBCon(); SqlCommand sqlcmd = new SqlCommand("spSelectAllCountries"); sqlcmd.Connection = sqlCon.OpenCon(); sqlcmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = sqlcmd.ExecuteReader(); DataTable dtTable = null; if (rdr.HasRows) { dtTable = new DataTable("countries"); dtTable.Load(rdr); status = true; return dtTable; } if (sqlcmd != null) { sqlcmd.Dispose(); sqlcmd = null; } return dtTable; }
string cs = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand sqlcmd = new SqlCommand("select * from Exam", con);
con.Open();
ddlExam.DataSource = sqlcmd.ExecuteReader();
ddlExam.DataTextField = "ExamNo";
ddlExam.DataValueField = "ExamName";
ddlExam.DataBind();
}
i have added this c# code in code behind. but do now how to do more!
Hi,
In data access layer add like this:
public DataSet BindDropDown(string id, string statename, DropDownList drpstate)
{
SqlParameter[] param = new SqlParameter[0];
{
ds = SqlHelper.ExecuteDataset(clscon.Con(), "Store procedure", param);
ds.Tables[0].TableName = "Table name";
drpstate.DataSource = ds.Tables[0];
drpstate.DataTextField = ds.Tables[0].Columns[statename].ColumnName.ToString();
drpstate.DataValueField = ds.Tables[0].Columns[id].ColumnName.ToString();
drpstate.DataBind();
drpstate.Items.Insert(0, new ListItem("[Select State]", "-1"));
drpstate.SelectedIndex = -1;
}
return ds;
}
and on page load
clsdal.BindDropDown("Valuefield", "Textfield", dropdownlist Id);
hope this help.
hi
i want to add one more field name "Interests " in createuserwizard tool as my requirement is to store user interests and then migrate to the interested pages whenever he logins...can anybody help me how to accomplish it
if we can store custom entities in CreateUserWizard then where can we find such entires in database table....i mean in which data table we can find user interest entry...
thanks
Hi it_ejaz,
From my understanding, you would like to custom the createuserwizard control.
If so, I suggest you to using ContentTemplate to implement.
Now, please try to refer to the following code:
In the aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CreateUserWizardFullApplication.WebForm1" %>
In the aspx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CreateUserWizardFullApplication
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Determine the checkbox values.
CheckBox subscribeCheckBox =
(CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
CheckBox shareInfoCheckBox =
(CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox");
TextBox userNameTextBox =
(TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName");
// Show or hide the labels based on the checkbox values.
Label subscribeLabel =
(Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel");
Label shareInfoLabel =
(Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel");
subscribeLabel.Visible = subscribeCheckBox.Checked;
shareInfoLabel.Visible = shareInfoCheckBox.Checked;
//Now you can store thest data to database...
}
}
}
Hope it can help you.
If there is anything unclear, please let me know.
Best Regards,
Terry Guo
Hi I have a list view created manually (not from visual studio wizards) that I dont know how to add an alternating row color to it. Its a bit tricky becasue each record I get back generates two table rows (although I can change if needed to achive the alt
row color). Here is my current code. Help appreciated. Thanks:
We didn't find anything. Please try again.
|
<%# Eval("WineName")%> |
<%# Eval("StoreName") %> |
|
Price Range:<%# Eval("PriceRange")%> |
<%# Eval("Address")%> |
Map it |
There is the AlternatingItemTemplate property that can be used to set the alternating row
...
|
...
|
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.alternatingitemtemplate.aspx
Alternatively you can use another way. From within any template, you have access to the current index of the row within the whole data set, using Container.DataItemIndex, and within the currently displayed items, using Container.DisplayIndex. This gives us an easy way to alternate styles:
">
...
Just define the even and odd classes in your stylesheet and you're pretty much done.
Hope this helps.
Hi All: I have a sqlDataSource bound to a listview with a simple updateCommand:
UpdateCommand="UPDATE dbo.appeals SET decision = @decision, findings = @findings, reason = @reason, dateOfDecision = getDate() where rowID=@rowID"
ConnectionString="<%$ ConnectionStrings:myConn %>" >
In my listview editItemTemplate, I have two textboxes and the ddl bound to the datasource:
When I debug and view the editItem...the ddl is being correctly set to the value of "decision", but if I change it and click "update", the text fields are updated, but the ddl value is not.
I tried trapping the value of the ddl in the "itemUpdating" event and assigning it to "e.NewValues("decision")" (and if I put a breakpoint in the code I see the correct value being assigned) but that doesn't work either. Not sure how one databound parameter
will update but the other won't when no error is being thrown?
UPDATE: I created a new page with a new datasource and listview, allowed the wizard to create the listview templates, substituted my dropdownlist above for the auto-generated text field, and it works fine...so something in my code seems to be interfering
with the ddlvalue being passed into the update parameters :(
hi dotnetnoob,
According to your description, i understand you want to bound in listview edititemtemplate value & update the data into dB .
You maybe simply set the
DataKeyNames e.g. DataKeyNames="rowID" and the SqlDataSource will figure it out for you when using ListView's Update and Delete feature.
Please read the reference below for more information:
ListView Update Parameters do not Bind
http://forums.asp.net/t/1534306.aspx
i hope it helps you.
I think it might be the dropdown binding issue. Try to rebind dropdown again on updating. May be this help.
Thank you,
Regards,
Imad Alavi
Hi Happy Chen: Thanks...As I mentioned, all the other databound fields are updating properly...only the dropdownlist is not. Datakeynames are already on the listview...but you just triggered something...
Typically I don't use the sqldatasource, and instead do all my listview datasource handling in codebehind...I thought I could save time by using the sqldatasource 
Usually I would bind the dropdownlist in the itemdatabound event. So initially, I had added "decision" to the datakeynames in the listview along with rowID, so I could set the selectedvalue in the edititemtemplate. I had left the ddl value in the datakeynames
along with rowID, even though I had removed the itemdatabound code.
So it seems that having the ddl value in the datakeynames was preventing it from updating, or causing it to re-bind the original value before updating?
Hi Emad: Thanks...the DDL was binding properly in the edititemtemplate, but the updated value was not being passed into the dB along with the other values.
Can you show me the code of passing values to the datasource?
Imad Alavi
Can you show me the code of passing values to the datasource?
Hi Imad: I showed it in the original post...I'm just binding the dropdownlist directly in the edititemtemplate, and I showed the update statement in the sqldatasource.
When I removed the column name from the "datakeynames" in the listview, the selected value in the dropdownlist started to update properly.
hi ,
if you do all your listview datasource handling in codebehind.
PLZ try this in the ItemUpdating event of ListView:
DropDownList NameDropDownList = (DropDownList)ListView1.Items[ListView1.EditIndex].FindControl("NameDropDownList");
'use your listview id.
Hello experts,
Am having issue with my gridview when I right click a page and do refresh. I have just 5 rows in my dataset and when I do a databind the 5 rows is binded to my page once I do a page refresh another 5 rows of same data is binded making it 10 rows on the gridview
control. It continue this way once I refresh. But I noticed this doesn't occur if I use gridview wizard to populate the data using sqldatasource. It happens only if I use code behind dataset.
you can clear your dataset on page postback and rebind it and assign to gridview.
Hello el_abhi
Am really confused as have been on this for a while now. can you help adjust my code below to reflect your profered solution;
If Page.IsPostBack Then
Try
GridView1.DataSource = Nothing
GridView1.DataBind()
Dim selSql As String = "select * from customers where customerid='ALFKI'"
sqlCom.CommandText = selSql
sqlCon.Open()
sqlAdp.Fill(dtS, "T_Customers")
GridView1.DataSource = dtS
GridView1.DataBind()
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlCon.Close()
End Try
End If
thank you.
Where you declared your dataset dtS? move that declaration part to just above sqlAdp.Fill(dtS,"T_Customers")
Hi,
Where are you declare dtS . please declare it within the module. and do not user shared modifier if you are using.
Hi
are you binding grid in IsPostBack event ?
if (isPostBack()==false){
//Bind grid
}
hi OyBosEnEmm ,
i would suggest you try to use the follow workaround:
If Not Page.IsPostBack Then
Try
GridView1.DataSource = Nothing
GridView1.DataBind()
Dim selSql As String = "select * from customers where customerid='ALFKI'"
sqlCom.CommandText = selSql
sqlCon.Open()
sqlAdp.Fill(dtS, "T_Customers")
GridView1.DataSource = dtS
GridView1.DataBind()
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlCon.Close()
End Try
End If
i hope it helps you.