You must Sign In to post a response.
  • Category: Visual Studio

    How can we retrive 3 combobox values and show it together in a textbox

    Sir i will attach the project below and the problem is that i have 3 combo box that is branch name, Course and Year after that 2 textbox for enrollment id and Registration Number. Sir i want that when user select the combobox values as like branch name is IKN,Course is DCA and the year is 14-15 then automatically the enrollment id generated as like <Branch Name/Course/Year/The last registered number according to particular course>
    sir the last registered number is according to the particular course as like there are 40 student are enrolled for DCA course then the number is 0040.
    After that the Registration number is also generated like this (Branch name/Total number of student registered). Sir this total number is the number of total student get enrolled.
  • #754238
    Sir Please Find the attachment bellow

    BASOFT-Ori.zip

    Delete Attachment

  • #754249
    Hi,

    You can do it by using your code. I assume that after choosing those checkboxes and other controls you are performing some action based on that action you want to generate the Id like above you mentioned.

    Refer below sample for your reference,


    protected void btnClick(object sender,EventArgs e)

    {
    string Id=chkselect1.SelectedItem.ToString()+"/"+chkselect2.SelectedItem.ToString()+"/"+....
    }


    You just concatenate the controls values and implement based on above sample.

    If you still struck in any place then let me know..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #754257

    Hai Sachin,
    As per the requirements,you need to do the below tasks:
    1. Get the last registration number for the particular course selected. This will be done when the user is selecting the particular course.

    private string GetLastRegistrationNumberForCourse(string course)
    {
    string registrationNumber = string.Empty;
    // create connection, command, datareader etc and get the last registration number by
    // passing the course name or id
    return string.Format(registrationNumber, ("0000"));
    }

    2. once you get the last registration number, you need to call this method when changing the course name drop-down as below:

    private void cmbCourse_SelectedIndexChanged(object sender, EventArgs e)
    {
    string registrationNumber = GetLastRegistrationNumberForCourse(cmbCourse.Text);
    txtEnrolmentID.Text = cmbBranchName.Text + "/" + cmbCourse.Text + "/" + cmbYear.Text + "/" + registrationNumber;
    //Registration number is also generated like this (Branch name/Total number of student registered)
    txtRegistrationNumber.Text = cmbBranchName.Text + "/" + registrationNumber;
    }

    With this code,you will get the last registration number for the selected course.
    3. Now you can assign these values to the text-box for the registration number and the enrollment number as below:

    private void cmbYear_SelectedIndexChanged(object sender, EventArgs e)
    {
    //enrollment id generated as like <Branch Name/Course/Year/The last registered number according to particular course>
    string registrationNumber = GetLastRegistrationNumberForCourse(cmbCourse.Text);
    txtEnrolmentID.Text = cmbBranchName.Text + "/" + cmbCourse.Text + "/" + cmbYear.Text + "/" + GetLastRegistrationNumberForCourse(cmbCourse.Text);
    //Registration number is also generated like this (Branch name/Total number of student registered)
    txtRegistrationNumber.Text = cmbBranchName.Text + "/" + registrationNumber;
    }

    Also I have attached your project with some modification.
    Hope it will be helpful to you.


    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

    BASOFT-Ori.zip

    Delete Attachment

  • #754349
    http://www.dotnetspider.com/member/pawansoftit.aspx
    Thanks a lot sir but there is a problem remains i can not understand how can i retrieve the last register number with creating the connection sir in the new attachment i create a connection to save all the data into database sir please update it with that code to retrive the last registration number of particuler course.

    BASOFT-Ori.rar

    Delete Attachment

  • #754371

    Hai Sachin,
    I already described it in previous posts.To retrieve the last registration number, you need to use the query:

    Select Max(RegNo)+1 from <tableName> Where CourseName= course

    Execute this using the ExecuteScalar as:

    private string GetLastRegistrationNumberForCourse(string course)
    {
    string registrationNumber = string.Empty;
    // create connection, command, datareader etc and get the last registration number by
    // passing the course name or id
    SqlConnection con= new SqlConnection("your connection string");
    SqlCommand cmd= new SqlCommand("Select Max(RegNo)+1 from <tableName> Where CourseName='"+ course+"'",con);
    con.Open();
    registrationNumber = Convert.ToString(cmd.ExecuteScalar());
    return string.Format(registrationNumber, ("0000"));
    con.Close();
    }

    Hope it will be helpful to you.


    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #754376
    http://www.dotnetspider.com/member/pawansoftit.aspx
    Sir i am not understanding that it gives an error that invalid column name RegNo. Sir from where i get registration number and i made a coulmn RegNo then how user gives his Registration Number sir please give a little bit time on my attachment. I attached my database and errors screenshot also.My data base name is "basoft" and the table name is "basoftori"

    BASOFT-Ori.zip

    Delete Attachment

  • #754378
    Hai Sachin,
    I am not sure that why you can't understand the code. If I provided the sample,you should understand that you will have a key column which will have the registration number. From the screenshot I can see that there is a Table called Registration, so don't you have the Registration number in it.
    You can use the same.
    I am not sure about how is your database and all.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #754386
    Sir Can I Call You..


  • Sign In to post your comments