Wednesday 8 August 2012

"Bind Data to text boxes from Database"

default.aspx;


<table>
<caption>Add Organizational Details</caption>
<tr><td>Organization Name</td><td>
    <asp:TextBox ID="txtON" runat="server"></asp:TextBox></td></tr>
 
 
    <tr><td>Business Sector</td><td>
    <asp:TextBox ID="txtBS" runat="server"></asp:TextBox></td></tr>
    <tr><td>WEbsite</td><td>
    <asp:TextBox ID="txtWebSite" runat="server"></asp:TextBox></td></tr>
    <tr><td>EmailID1</td><td>
    <asp:TextBox ID="txtEmail1" runat="server"></asp:TextBox></td></tr>
    <tr><td>EmailID2</td><td>
    <asp:TextBox ID="txtEmail2" runat="server"></asp:TextBox></td></tr>
    <tr><td>Address</td><td>
    <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td></tr>
    <tr><td>Organizational Enviroment</td><td>
        <asp:DropDownList ID="ddlOE" runat="server">
            <asp:ListItem Selected="True">Excellent</asp:ListItem>
            <asp:ListItem>Good</asp:ListItem>
            <asp:ListItem>Fair</asp:ListItem>
        </asp:DropDownList>
    </td></tr>
    <tr><td>Term and Condition</td><td>
    <asp:TextBox ID="txtTermCondition" runat="server"></asp:TextBox></td></tr>
    <tr><td>Size of Organization</td><td>
    <asp:TextBox ID="txtSizeOrganization" runat="server"></asp:TextBox></td></tr>
    <tr><td>
        <asp:Button ID="btnInsert" runat="server" Text="Save"
            onclick="btnInsert_Click" /><asp:Button ID="btnUpdateRecord" runat="server"
            Text="Update" onclick="btnUpdateRecord_Click" /></td><td><asp:Button ID="btnUpdate" runat="server"
                Text="Show" onclick="btnUpdate_Click" /></td>
             
                </tr>
    </table>

// ******* Call Method on Click*************

protected void btnShow_Click(object sender, EventArgs e)
    {
        RecordBindData();
    }

//************** Fetch User Profile
    private void RecordBindData()
    {

        DataSet ds = new DataSet();
        rog.rName = Session["UserLogin"].ToString();
       ds= rog.ShowRecruiterProfile();
       if (ds.Tables[0].Rows.Count > 0)
       {
           DataRow dr = ds.Tables[0].Rows[0];
           txtON.Text = dr[2].ToString();
           txtBS.Text = dr[3].ToString();
           txtWebSite.Text = dr[4].ToString();
           txtEmail1.Text = dr[5].ToString();
           txtEmail2.Text = dr[6].ToString();
           txtAddress.Text = dr[7].ToString();

           txtTermCondition.Text = dr[9].ToString();
           txtSizeOrganization.Text = dr[10].ToString();
       }
       else
       {
           ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", @"alert('No Data Found');", true);
       }
 
    }

//************** RecordBindData

 public DataSet fetchUserProfile()
        {
            SqlCommand cmd = new SqlCommand("sp_RODFetch", (SqlConnection)Ncconnection.cconnection.MConnection());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@RUserName", this._recruiterName);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);

            return ds;
        }



No comments:

Post a Comment