Click here to Skip to main content
15,917,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m working on One MLM Software project as Jr.developer now in this application one administrator is there now i have working with editing the web form for that Admin..... now suppose if i want to edit data of admin like address mobile no email ID Phone NO........and one text box is there for admon name that will never change so whenever admin want to update his/her data that name should be bind on that textbox each and every time cliclk on that text box means simply i want to bind that name from database.......i m strongly working with 3 Tier application so there should be DAL file BLL FIle and MY project....so what should be the coding for that???
Posted
Comments
[no name] 23-Aug-12 12:37pm    
So you want someone to write up all this code for you based on this vague description? Or did you have something more in line with a specific question?
ridoy 23-Aug-12 14:12pm    
i don't understand question at all!

Your DAL would contain a method to return the text based on what ids are needed and you'd do myTextBox.Text = DAL.GetText(id);
 
Share this answer
 
Your question is not very specic. Though, what I have understood, you need to edit a page where you will edit all the details address, mobile, email etc but never the name.

I am not clear what you mean to say binding data to name in every click.
But what I guess is you want the name to be shown in the text box but, user cannot change edit the textbox.

If this is the thing you want, my friend you have thought too far.

Simply populate the data into all textbox, dropdown etc in pageload event.
After the populate code, just disable name textbox control.

Here is the code

aspx page
<div>
    <asp:label id="Label1" runat="server" text="Admin Name" xmlns:asp="#unknown"></asp:label>
    <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
    <br />
    <asp:label id="Label2" runat="server" text="Email" xmlns:asp="#unknown"></asp:label>
    <asp:textbox id="TextBox2" runat="server" xmlns:asp="#unknown"></asp:textbox>
    <br />
    <br />
    <asp:button id="Button1" runat="server" onclick="Button1_Click" text="Edit" xmlns:asp="#unknown" />
</div>


code behind
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //populate from database
        DataTable dtblClient = doPopulate();
        foreach (DataRow dr in dtblClient.Rows)
        {
            TextBox1.Text = dr["name"].ToString();
            TextBox2.Text = dr["email"].ToString();
        }

        //make the name textbox disable
        TextBox1.Enabled = false;
        dtblClient.Dispose();
    }
}
private DataTable doPopulate()
{
    //call databse to get the data as reader or datatable
    //here in the e.g, I create a custom datatable
    DataTable dtbl = new DataTable();
    dtbl.Columns.Add(new DataColumn("id", Type.GetType("System.Int32")));
    dtbl.Columns.Add(new DataColumn("name", Type.GetType("System.String")));
    dtbl.Columns.Add(new DataColumn("email", Type.GetType("System.String")));

    dtbl.Rows.Add(new object[]{1, "Sandip", "sandip@test.com"});

    return dtbl;
}


Hope this helps.
cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900