Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have the user enter an address in my database. Which control is better to display that address beautifully on my page?
I need below structure:

name,
city-1010,
state,
country.

Can you please help me?
Posted
Updated 5-Jan-11 2:01am
v2
Comments
Hiren solanki 5-Jan-11 8:08am    
see my updated answer.

I think div will be best to represent it IF you're storing address in HTML Encoded.

Are you storing address in single column in DB or you have spitted it to multiple column ?

[update]

Thanks for the update. So If you are storing in single column then split the address with ' '(Space) and gather address lines(in case of you there will be 4)

Then simply add <br/> after each line and put the whole string in div. Do you think it makes sense to you ?
 
Share this answer
 
v3
Comments
srinivasvempa 5-Jan-11 8:03am    
i have to split address there is no proper data user can enter any address as his like
srinivasvempa wrote:
i should use asp.net control like label,textbox.... for displaying that address


Align/Design your controls based on your need in you page & write the below code in the code-behind.
C#
string Details = "Name;City;State;Country";
string[] arDetails = new string[4];
char[] splitter  = {';'}; //Define deliminator based on the original string
arDetails = Details.Split(splitter);
for(int x = 0; x < arDetails.Length; x++)
{
    switch(x)
{
    case 0:
    lblName.Text = arDetails[x].ToString();
    break;
    case 1:
    lblCity.Text = arDetails[x].ToString();
    break;
    case 2:
    lblState.Text = arDetails[x].ToString();
    break;
    case 3:
    lblCountry.Text = arDetails[x].ToString();
    break;
}
}

Do changes in your code based on your need.
 
Share this answer
 
Yes div is good option, it si light weighted but if you have knowledge of html designing and css (because i confused in margin and padding). i created the sample code using table. becaus in tabel we are esy to handle and able to align properly and also have proper browser compatibility.
<table width="600px" style="vertical-align:middle">
          <tr>
              <td>
                  <asp:Label runat="server" Text="Name" ID="lblName"></asp:Label>
              </td>
              <td>
                  <asp:TextBox runat="server"  ID="txtName"></asp:TextBox>
              </td>
              <td>
                  <asp:Label runat="server" Text="City" ID="lblCity"></asp:Label>
              </td>
              <td>
                  <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
              </td>
          </tr>
          <tr>
              <td>
                  <asp:Label runat="server" Text="State" ID="lblState"></asp:Label>
              </td>
              <td>
                  <asp:TextBox runat="server" ID="txtState"></asp:TextBox>
              </td>
              <td>
                  <asp:Label runat="server" Text="Country" ID="lblCountry"></asp:Label>
              </td>
              <td>
                  <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
              </td>
          </tr>
      </table>



Hope it will help to you.
 
Share this answer
 
Use HTML Table and respective tr and tds. And if you are displaying multiple user details then use gridview to bind the data from db
 
Share this answer
 
Comments
srinivasvempa 5-Jan-11 8:16am    
thanks i should use asp.net control like label,textbox.... for displaying that address

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