get data from database RRS feed

  • Question

  • User-265772647 posted


    i have two webforms .webform1 and webform2


    startdate  txbx (date populates in labels below linkbtns) 01/02/2014

    enddate     txbx         01/07/2014                                        



    sunliknbtn      suntextbox


    monlinkbtn     monextbox


    tueslinkbtn     tuestextbox



    wednesbtn     wedtextbox


    if user click on tueslinkbtn

                                 day(tues)       date(01/04/2014)


    dropdown1 (options)a

    dropdown2         b

    dropdown3          c


    okbtn//user clicks save in database (a,b,c)


    depending updon user  clicks sunlinkbtn or monlinkbtn  it get data from database and populate into regarding textbox



     string Connection = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
            SqlConnection cn = new SqlConnection(Connection);
                string strcmd = "select Services from DetailsTable where date =@Services ";
                SqlCommand command1 = new SqlCommand(strcmd, cn);
                command1.Parameters.AddWithValue("@Services", SqlDbType.DateTime);
                command1.Parameters["@Services"].Value = txt_StartDate.Text;
                SqlDataReader dr;
                dr = command1.ExecuteReader();
                var count = dr.FieldCount;
                txt_ServiceMonday.Text = "";
                while (dr.Read())
                    for (int i = 0; i < count; i++)
                        txt_ServiceMonday.Text += dr.GetValue(i) + ",";

    above code i plave in startdatetextbox  so whenever i click on that it display only in one textbox.waht  modification do i need to do

    Friday, January 10, 2014 2:15 PM

All replies

  • User1508394307 posted

    waht  modification do i need to do

    It is clear that you have 2 web forms but it is not clear what you want to do with them. Can you maybe provide some more details regarding your problem?

    Friday, January 10, 2014 3:34 PM
  • User-265772647 posted

    in webform2 employee select some dropdown services  hits okbtn it stores in databse and redirects to webform1.Iwant to display dropdown values should be displayed in textbox .

    example: in timesheet employee selects  different projects when closes the form those projects are diplayed in main page  something like this(in my program  employee enters data into database  and saves  after he closes form display those values into main webform.

    Friday, January 10, 2014 4:36 PM
  • User1508394307 posted

    select some dropdown services  hits okbtn it stores in databse and redirects to webform1.

    If you save data in the database and then want to show data from the database on other form then you simply need to query database, get data and show on the form.

    You already have some code with query

    "select Services from DetailsTable where date =@Services ";

    If I understand it correct you now need to have 

    "select something from SomeTable where userid=@userid";

    Friday, January 10, 2014 5:04 PM