473,653 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-WEB:Want to display the autoincrement id on the label or textbox control

20 New Member
Hello friends,

I m using ASP.NET with C# 2005 and SQL SERVER 2005 for the ASP.Net Website.

I m using sqldatasource to connect and retrieve the data from database and then it displays the data in the gridview on the button click event.I have created the stored procedure for insert and select query.

I Want to display the autoincrement id on the label or textbox control on the form and also on the click event of the button it should display in the gridview.

I m able to get the data thru database and display it in the gridview but i don't know how'z it possible to see the id on the label or textbox control of the form ??

The form has many other controls also when it clicks on submit then on that click event it should show me the data on the control which should be retrieve from database..

On view click event it shows the contains in gridview at that time it show the id incremented n all data.

Pls help me how can i see the id on the label..
Thanxs in advance.
Apr 9 '07 #1
3 6084
AricC
1,892 Recognized Expert Top Contributor
A few things, what does your table structure look like? Do you have a value that auto increments? If you are getting the other data you should be able to select the ID and update a the label. Perhaps some code would help.
Apr 9 '07 #2
sheenaa
20 New Member
A few things, what does your table structure look like? Do you have a value that auto increments? If you are getting the other data you should be able to select the ID and update a the label. Perhaps some code would help.

No,ur understanding is wrong...
I m not able to explain my question properly sorry...

ASP.NET with C# 2005 code

Expand|Select|Wrap|Line Numbers
  1.  <body>
  2. <form id="form1" runat="server">
  3. <div>
  4. Id   
  5. <asp:TextBox ID="tbid" runat="server" Enabled="False"></asp:TextBox>
  6. <br />
  7. Address   
  8. <asp:TextBox ID="tbaddress1" runat="server" Rows="4" TextMode="MultiLine" ></asp:TextBox>
  9. <br />
  10.  
  11. <asp:Button ID="cmdview" runat="server" Text="View" OnClick="cmdview_Click" />
  12. <br />
  13.  
  14. <asp:SqlDataSource ID="SqlDataSource1" runat="server"
  15. ConnectionString="<%$ ConnectionStrings:addresstable%>"
  16. ProviderName="System.Data.SqlClient"
  17. Selectcommandtype="StoredProcedure" SelectCommand="addressSelect "
  18. </asp:SqlDataSource>
  19.  
  20. <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" autogeneratecolumns="false"
  21. AutoGenerateDeleteButton="false" AutoGenerateEditButton="false"
  22. DataKeyNames=id>
  23.  
  24. <Columns>
  25. <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
  26. <asp:boundfield datafield="id"
  27. readonly="True"
  28. headertext="ID"/>
  29. <asp:boundfield datafield="address"
  30. headertext="Address"/>
  31. </Columns>
  32.  
  33. </asp:GridView>
  34.  
  35. </div>
  36. </form>
  37. </body>
  38.  
  39.  
  40. protected void Page_Load(object sender, EventArgs e)
  41. {
  42. GridView1.Visible = true;
  43.  
  44.  
  45.  
Stored Procedure

Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER PROCEDURE insertquery1
  3.  
  4. @id Int output,
  5. @address varchar(30)
  6.  
  7. AS
  8.  
  9. if not exists (Select address from addresstable where address=@address and id <> @id)
  10.  
  11. begin 
  12.            select @id = isnull(max(id),0) + 1 from addresstable
  13. INSERT INTO addresstable
  14.                     ( address)
  15. VALUES     (@address)
  16.                 Print ' Address are now recorded'  
  17. end
  18.  
Apr 12 '07 #3
sheenaa
20 New Member
The above code is just a sample which may help now to answer my question i suppose...if anything missing then let me know again...

Ok,now i want to display the 2fields in gridview i.e. ID and Address..which i will insert thru the insert parameters

Expand|Select|Wrap|Line Numbers
  1.  
  2.  <asp:Button ID="cmdsubmit" runat="server" Text="Submit" OnClick="cmdsubmit_Click" />&nbsp;
  3.  
  4.  
  5.  protected void cmdsubmit_Click(object sender, EventArgs e)
  6.     {
  7.        SqlDataSource1.InsertParameters["address"].DefaultValue =tbaddress.Text;
  8.  
  9.  
  10.        HOW TO MAKE THE LABEL/TEXTBOX DISPLAY WHICH IS ENABLED IN THE PROPERTY AND WHICH IS AUTOINCREMENT WITH IDENTITY THRU STORED PROCEDURE OF SQL SERVER 2005  
  11.  
  12.         SqlDataSource1.Insert();
  13.         GridView1.Visible = true;
  14.      }
  15.  

HOW TO MAKE THE LABEL/TEXTBOX DISPLAY WHICH IS Enabled="False" PROPERTY AND WHICH IS AUTOINCREMENT WITH IDENTITY THRU STORED PROCEDURE OF SQL SERVER 2005.

I don't want the user manually inserts the id as it is autoincrement but at the time of entering the address he can know the id and see it in the enabled textbox.If it's possible to display in the label then also it's fine..

Hope this time anyone can understand what i want and explain me..
thanxs
Apr 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4509
by: Rab | last post by:
hi i need to programmatically change the caption of a label that is linked to another control (i.e. textbox, combobox). it's for a generic function where i only know the textbox/combobox name but not the name of the label that is linked to the textbox/combobox. example sub: public sub ReSetCaption()
3
1613
by: Leo | last post by:
Thanks for the Help in Advance!! I am a beginner in VB.Net. I am trying to create a form which is displayed in a email for our customers to fill in a Request for quote. I would like them to type data into fields and have it added to the Datagrid. I am constantly getting the error Column 'OALen' does not belong to table . Any Ideas? Public tblJobItems As New DataTable
6
10705
by: tfs | last post by:
I am trying to display some data that is about 200 characters long and I was trying to display it on the screen in a textbox <asp:textbox /> But I don't want any borders. How would I display that? Thanks,
0
1900
by: Deepak C.G via .NET 247 | last post by:
I want to dispose the image object in my child form, unless I won't dispose this object i can't delete the image file in my folder. I get this error in MDIparent form "An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll" "Additional information: Invalid parameter used." Here is my code:-
1
4031
by: maflatoun | last post by:
Hi, I have a datagrid and based on a condition I like to display either a asp:textbox or asp:label. How would I do that? I have the following <asp:TemplateColumn HeaderText="Qty"> <ItemTemplate> <% if (DataBinder.Eval(Container.DataItem, "DynamicAttribute") = "No") {%>
11
11142
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in a text box. I know that there are certain control characters embedded in the data that I want to display substitutions for in the text box, for instance I want to replace ASCII character 04 with the string "<EOT>". I have tried doing a simple...
1
2612
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. Included in the application program is a data “GRID” which I believe was created using Visual Basic, not standard Access. Its purpose is to display the results of a range of “from-to-dates” of registrations for different clients. The difficulty...
1
2282
by: Benny Ng | last post by:
Dear All, Now I met one problem in the development of my one application. I have one ASP.NET page. It's for disply the information of customer. But now I have one new requirement. It's to combine the "Edit" and "Display" funtions into this page. (It means if user want to edit the customer information, this page would provided editing page to the user; If the user want to display the customer information, this page would providev the...
6
5302
by: Gilberto | last post by:
Hello I have a table (BOM TOTAL L1 V1) created by a query which only contains one field (TCL1) with ONE record. I've been trying to display this record on a form (either in a textbox or a label) so i can them make some calculations with this number but i CANT!!! I have tried different things and nothing. I get error "#Name?" when entering =! on the unbounded textbox. Should the textbox or label be BOUND??? UNBOUND???
7
3467
by: TechnoAtif | last post by:
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone help..through php or javascript. ONe more thing..How can i perform the same function for more than one such kind of problem..I mean if there is any other place in the form where i have to display textbox on selecting a particular value.how can it be...
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.