473,503 Members | 1,136 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 6063
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
4499
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...
3
1609
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...
6
10700
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...
0
1893
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...
1
3990
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">...
11
11097
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...
1
2602
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. ...
1
2272
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...
6
5290
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)...
7
3449
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...
0
7282
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,...
1
6995
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...
0
7463
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...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5017
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...
0
3168
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...
0
1515
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 ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
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...

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.