顯示具有 Wizard 標籤的文章。 顯示所有文章
顯示具有 Wizard 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] Crystalreport USer Logon


Hello,


I am trying to genrate report, and I have done all the necessery database connections but I cannot view my report,its asking for information during logon and If I disable Logon, its saying Database Logon failed!!.


So here's the Code.what changes do I have to do,or I have use other type of connection..Can anyone help




using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;



public partial class Default2 : System.Web.UI.Page

{

    Cont1 ctn = new Cont1();

    DataSet ds = new DataSet();

    //DataSet ds2 = new DataSet();

    //store ss1 = new store();

    protected void Page_Load(object sender, EventArgs e)

    {

        ctn.conn();

        //ss1 = Session["data2"] as store;

        //ctn.billing(ss1.bino);

        ReportDocument report = new ReportDocument();

        string reportpath = Server.MapPath("CrystalReport.rpt");

        report.Load(reportpath);

        report.SetDataSource(ctn.ds2.Tables["billDetails"]);

        CrystalReportViewer1.ReportSource = report;

    }

}



MARKUP



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>



<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>











   





   



   


    

       
            AutoDataBind="True" GroupTreeImagesFolderUrl=""

            Height="1202px" ReportSourceID="CrystalReportSource1"

            ReuseParameterValuesOnRefresh="True"

            style="z-index: 1; left: 10px; top: 15px; position: absolute; height: 50px; width: 722px"


            ToolbarImagesFolderUrl="" ToolPanelView="None" ToolPanelWidth="200px"


            Width="903px" ToolbarStyle-BorderStyle="None" />

       
            CacheDuration="100">

           

           


       


    

   


   






Cont1 class


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data.SqlClient;

using System.Data;



///



/// Summary description for Cont1

///


public class Cont1

{

    public SqlConnection cn;

    public SqlDataAdapter da;

    public SqlCommand cm;

    public SqlCommand cm2;

    public DataSet ds = new DataSet();

    public DataSet ds2 = new DataSet();

    int r_val;



    public Cont1()

    {

        //Contructor logic

    }



    public void conn()

    {

        cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Proj\BookStore\BookStore_Web\App_Data\BookStore.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");

        cn.Open();

    }



    //public void connn()

    //{

    //    cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Proj\BookStore\BookStore_Web\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True");

    //    cn.Open();

    //}

    public void fetch(string query)

    {

        da = new SqlDataAdapter(query, cn);

        ds.Clear();

        ds.Reset();

        da.Fill(ds);

    }



    public int dmlsmt(string query)

    {

        cm = new SqlCommand(query, cn);

        r_val = cm.ExecuteNonQuery();

        //cn.Close();

        return r_val;

    }



    //public void ref_usr()

    //{

    //    cm = new SqlCommand("usr_test", cn);

    //    cm.CommandType = CommandType.StoredProcedure;

    //    cm.ExecuteNonQuery();

    //}

    public bool str_pay(string user,string blno)

    {

        cm2 = new SqlCommand("bkPayMod", cn);

        cm2.CommandType = CommandType.StoredProcedure;

        cm2.Parameters.Add("@billno", blno);

        cm2.Parameters.Add("@member", user);

        cm2.ExecuteNonQuery();

        //cn.Close();

        return true;

    }

    public void billing(string bino)

    {

        da=new SqlDataAdapter("EXEC billDetailsOne @billno= " + bino, cn);

        ds2.Clear();

        ds2.Reset();

        da.Fill(ds2,"billDetailsOne");

        //da=new SqlDataAdapter("EXEC billDetailsTwo @billno= " + bino, cn);

        //ds2.Clear();

        //ds2.Reset();

        //da.Fill(ds2,"billDetailsTwo");

        return;

    }

}



Hi,


Please check whether you have given the user credentials both while designing the crystal report and in the code. it should work. The logon credentials which you give in the wizards should also match the logon credentials in your code.


Source from http://forums.asp.net/t/1206308.aspx


And you can also refer here about dynamic logon in crystal reports:


http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-dynamic-login.htm


Hope it can help you.


[RESOLVED] Can&#39;t set IsApproved to false


I am explicitly disable the user upon creation but the IsApproved property is set to TRUE and so the user is able to login. I want the user to be disabled after cregistering and they'll activate the account by licking on a linkin the email they'll get upon
registering. Any idea what is wrong?


        OnCreatedUser="RegisterUser_CreatedUser">







I resolved it. I had it as DisableCreateUser="True" instead of DisableCreatedUser="True"


[RESOLVED] Register users based on e-mail list


Hi all,


I am using CreateUserWizard to let users register on my web application. My requirement is to only let users register if the email they enter while registering exists in my database(i have a table with all the valid emails). I did a lot of research and came
across this similar requirment here http://stackoverflow.com/questions/9476820/asp-net-register-users-based-on-e-mail-whitelist. but how can I stop the
registration if the email doesn't exist in my database?Since am using the CreateUserWizard , do I have control over stopping the registration?


Please advise and thanks for the help.


[RESOLVED] CreateUserWizard custom error message


Hi All,


I am using CreateUserWizard to setup a registration page for users. I don't want the registration to happen for certain email addresses so am using the code below and it works fine. How can I give a custom error message to the user when they use an "invalid"
email? Thanks for the help.



protected void ValidateEmail_CreatingUser(object sender, LoginCancelEventArgs e)
{
if (RegisterUser.Email == "some-email@company.com")
{
e.Cancel = true;
}

}





Any ideas, please?



hi  sam1980, 


Acording to your description ,you want to create CreateUserWizard custom error message.


You  can  try   using  custom templates and use RegularExpressionValidator
control. for example ,html  source code as below :


         


           


               


                     


                       


                            ……


                            


                               


                                


                           

                          


                            


                               


                           


                       


                                                       E-mail:


                                   


                                   

                                        ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*                           


                                   *@\w+([-.]\w+)*\.\w+([-.]\w+)*"


                                 ControlToValidate="Email"   runat="server"        ErrorMessage="E-mail format is error">


                               


                                   


                               

                       


                    


               


               


                      ……


               


             


          


          Or trigger control event to judge.


[RESOLVED] populate dropdownlist from dataview


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = New ListItem

For Each r As DataRowView In dv1
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next

adds the correct number of items to the dropdownlist, but every
item in the list is the last one:


For example, instead of



  • Item 1
  • Item 2
  • Item 3

I get



  • Item 3
  • Item 3
  • Item 3



Try like this: if you can, use dropdownlist


 DropDownList li = new DropDownList();


li.datasource=dv1;


li.datatextfield="Projectname";


li.datavaluefield="Id";


li.databind();



Maybe you can use


ddlWProjectName.DataSourceId="sdsWizard"

set ddl DataTextField and DataValueField then call DataBind() Or


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
ddlWProjectName.DataSource = dv1.Table
ddlWProjectName.DataTextField = "ProjectName"
ddlWProjectName.DataValueField = "ID"
ddlWProjectName.DataBind()







spokey,


actully you are only creating only one li for all the gridView rows, as your Dim li = New ListItem is out-side the loop just change your code as,


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = Nothing

For Each r As DataRowView In dv1
li = New ListItem
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next







Thanks ijaz! works like a charm now.



pooja and oned, thanks for the suggestion but databinding didn't change anything.


manish- that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)





spokey


that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)




happy to help


thanks


manish



[RESOLVED] populate dropdownlist from dataview


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = New ListItem

For Each r As DataRowView In dv1
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next

adds the correct number of items to the dropdownlist, but every
item in the list is the last one:


For example, instead of



  • Item 1
  • Item 2
  • Item 3

I get



  • Item 3
  • Item 3
  • Item 3



Try like this: if you can, use dropdownlist


 DropDownList li = new DropDownList();


li.datasource=dv1;


li.datatextfield="Projectname";


li.datavaluefield="Id";


li.databind();



Maybe you can use


ddlWProjectName.DataSourceId="sdsWizard"

set ddl DataTextField and DataValueField then call DataBind() Or


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
ddlWProjectName.DataSource = dv1.Table
ddlWProjectName.DataTextField = "ProjectName"
ddlWProjectName.DataValueField = "ID"
ddlWProjectName.DataBind()







spokey,


actully you are only creating only one li for all the gridView rows, as your Dim li = New ListItem is out-side the loop just change your code as,


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = Nothing

For Each r As DataRowView In dv1
li = New ListItem
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next







Thanks ijaz! works like a charm now.



pooja and oned, thanks for the suggestion but databinding didn't change anything.


manish- that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)





spokey


that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)




happy to help


thanks


manish



[RESOLVED] populate dropdownlist from dataview


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = New ListItem

For Each r As DataRowView In dv1
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next

adds the correct number of items to the dropdownlist, but every
item in the list is the last one:


For example, instead of



  • Item 1
  • Item 2
  • Item 3

I get



  • Item 3
  • Item 3
  • Item 3



Try like this: if you can, use dropdownlist


 DropDownList li = new DropDownList();


li.datasource=dv1;


li.datatextfield="Projectname";


li.datavaluefield="Id";


li.databind();



Maybe you can use


ddlWProjectName.DataSourceId="sdsWizard"

set ddl DataTextField and DataValueField then call DataBind() Or


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
ddlWProjectName.DataSource = dv1.Table
ddlWProjectName.DataTextField = "ProjectName"
ddlWProjectName.DataValueField = "ID"
ddlWProjectName.DataBind()







spokey,


actully you are only creating only one li for all the gridView rows, as your Dim li = New ListItem is out-side the loop just change your code as,


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = Nothing

For Each r As DataRowView In dv1
li = New ListItem
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next







Thanks ijaz! works like a charm now.



pooja and oned, thanks for the suggestion but databinding didn't change anything.


manish- that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)





spokey


that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)




happy to help


thanks


manish



[RESOLVED] populate dropdownlist from dataview


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = New ListItem

For Each r As DataRowView In dv1
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next

adds the correct number of items to the dropdownlist, but every
item in the list is the last one:


For example, instead of



  • Item 1
  • Item 2
  • Item 3

I get



  • Item 3
  • Item 3
  • Item 3



Try like this: if you can, use dropdownlist


 DropDownList li = new DropDownList();


li.datasource=dv1;


li.datatextfield="Projectname";


li.datavaluefield="Id";


li.databind();



Maybe you can use


ddlWProjectName.DataSourceId="sdsWizard"

set ddl DataTextField and DataValueField then call DataBind() Or


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
ddlWProjectName.DataSource = dv1.Table
ddlWProjectName.DataTextField = "ProjectName"
ddlWProjectName.DataValueField = "ID"
ddlWProjectName.DataBind()







spokey,


actully you are only creating only one li for all the gridView rows, as your Dim li = New ListItem is out-side the loop just change your code as,


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = Nothing

For Each r As DataRowView In dv1
li = New ListItem
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next







Thanks ijaz! works like a charm now.



pooja and oned, thanks for the suggestion but databinding didn't change anything.


manish- that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)





spokey


that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)




happy to help


thanks


manish



[RESOLVED] populate dropdownlist from dataview


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = New ListItem

For Each r As DataRowView In dv1
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next

adds the correct number of items to the dropdownlist, but every
item in the list is the last one:


For example, instead of



  • Item 1
  • Item 2
  • Item 3

I get



  • Item 3
  • Item 3
  • Item 3



Try like this: if you can, use dropdownlist


 DropDownList li = new DropDownList();


li.datasource=dv1;


li.datatextfield="Projectname";


li.datavaluefield="Id";


li.databind();



Maybe you can use


ddlWProjectName.DataSourceId="sdsWizard"

set ddl DataTextField and DataValueField then call DataBind() Or


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
ddlWProjectName.DataSource = dv1.Table
ddlWProjectName.DataTextField = "ProjectName"
ddlWProjectName.DataValueField = "ID"
ddlWProjectName.DataBind()







spokey,


actully you are only creating only one li for all the gridView rows, as your Dim li = New ListItem is out-side the loop just change your code as,


dv1 = CType(sdsWizard.Select(DataSourceSelectArguments.Empty), DataView)
Dim li As ListItem = Nothing

For Each r As DataRowView In dv1
li = New ListItem
li.Text = r("ProjectName").ToString
li.Value = r("ID").ToString
ddlWProjectName.Items.Add(li)
Next







Thanks ijaz! works like a charm now.



pooja and oned, thanks for the suggestion but databinding didn't change anything.


manish- that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)





spokey


that link is a good resource of a cleaner way to do it, I'll reference it for next time around (which I'm sure will be soon) :)




happy to help


thanks


manish



[RESOLVED] Bind Country/State DDL


I have two Dropdownlists within a CreateuserWizard. One for Country and the other for State. I also have two sqldatasources. I am trying to load the state dropdownlist based on the selection of the the country dropdownlist. The state dropdownlist is not
populating.


 




                    OnCreatedUser="RegisterUser_CreatedUser" BackColor="#F7F6F3"
BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em">


Country:
ForeColor="Black" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="CountryName" DataValueField="Country#"
onselectedindexchanged="ddlCountry_SelectedIndexChanged">

CssClass="failureNotification" ErrorMessage="Country is required." ToolTip="Country is required."
ValidationGroup="RegisterUserValidationGroup">*




State:
ForeColor="Black" DataSourceID="SqlDataSource2"
DataTextField="StateName" DataValueField="State#" AutoPostBack="True">

CssClass="failureNotification" ErrorMessage="State is required." ToolTip="State is required."
ValidationGroup="RegisterUserValidationGroup">*





ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Country]">



ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT State.State#, State.StateName FROM State INNER JOIN StateCountry ON State.State# = StateCountry.State# WHERE (StateCountry.Country# = @column1)">







protected void Page_Load(object sender, EventArgs e)
{
RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];


if (!Page.IsPostBack)
{
DropDownList stateList = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("ddlState");
DropDownList countryList = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("ddlCountry");
Session["countryID"] = countryList.SelectedValue.ToString();
stateList.DataBind();
}


}



 


 




Use control parameter instead. You don't need to write some code behind to populate ddlState items. Don't join the table, simply set criteria.

Error :


Could not find control 'ddlCountry' in ControlParameter 'column1'.


I also tried countryList.



Maybe you can place Country/State DDL, SqlDataSource in same template



hello


try somthing like this


Session["countryID"] = countryList.SelectedValue.ToString();
// first clear statelist then assign value
stateList.ClearSelection();
stateList.DataBind();

hope this works for you 


thanks


manish








try the following code ,



hopfully it will help.





Hi Code_warrior...,


As oned_gk suggested, using ControlParameter would be better here. Also, for the following error you encountered:


"Could not find control 'ddlCountry' in ControlParameter 'column1'."


it is due to the SqlDataSource control cannot locate the dropdownlist control (ddlCountry) inside the CreateUserWizard control (they are not in the same container). As oned_gk suggested, you can try putting the SqlDataSource control into the CreateUserWizard
(make them in the same container) to see if it works.


[RESOLVED] Display Photo in Item Template


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.







You can have the two options like bellow Hope it helps for you

option 1:



  
        ImageUrl='<%# Eval("Path") %>' />





option 2:


     DataImageUrlFormatString="~/images/{0}.jpg">


For refer


http://www.aspdotnet-suresh.com/2011/01/how-to-insert-images-into-database-and.html


http://msdn.microsoft.com/en-us/library/aa479350.aspx






                                                       

                                                           

                                                               
                                                                    Width="70px" Height="50px" />

                                                          

                                                           

                                                       


                                                   


in aspx.cs page


 public string GetImageURL(string url)

    {

      

        string taxid = url;

   



        taxid = "~/UploadedDocument/VehiclePhoto/" + url+".jpg" ;



        return taxid;

    }


[RESOLVED] Pie Chart Labels


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





Thanks jats_ptl



Glad Mike that I could help you.. Smile


[RESOLVED] Pie Chart Labels


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





Thanks jats_ptl



Glad Mike that I could help you.. Smile


[RESOLVED] Bind Drop down to a sql table column in 3 tier architecture


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.




[RESOLVED] In createuserwizard,can i add more fields other than default entries


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" %>
















































Sign Up for Your New Account


User Name:


ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*


Password:


ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*


Confirm Password:


ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
ValidationGroup="CreateUserWizard1">*



E-mail:


ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*


Security Question:


ErrorMessage="Security question is required." ToolTip="Security question is required."
ValidationGroup="CreateUserWizard1">*



Security Answer:


ErrorMessage="Security answer is required." ToolTip="Security answer is required."
ValidationGroup="CreateUserWizard1">*


ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="CreateUserWizard1">





















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


[RESOLVED] Alternating Row Color List View


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.















Label
Wine

Store






<%# 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.


[RESOLVED] dropdownlist bound in listview edititemtemplate value not updating in dB


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 Foot in Mouth


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.


 



[RESOLVED] Gridview duplicate rows on page refresh


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.