473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting ID from datagrid to a label

8
Hi Frends...........

I want to display the Id of the field which we are updating through datagrid in to a label.

i tried in one way..

Label2.Text = e.Item.Cells[0].Text.ToString();

But its nit returns the Id..Can anyone help me pls..
Sep 18 '07 #1
7 922
dip_developer
648 Expert 512MB
Hi Frends...........

I want to display the Id of the field which we are updating through datagrid in to a label.

i tried in one way..

Label2.Text = e.Item.Cells[0].Text.ToString();

But its nit returns the Id..Can anyone help me pls..
in which event of Datagrid you are writing this code????
Sep 18 '07 #2
Dyny
8
in which event of Datagrid you are writing this code????
Hiii.........

Itemcommand event of the datagrid....
Sep 18 '07 #3
dip_developer
648 Expert 512MB
Hiii.........

Itemcommand event of the datagrid....
try this code......assuming that your button CommandName is Select

Expand|Select|Wrap|Line Numbers
  1.  if ( e.CommandName=="Select") 
  2. {
  3. Label1.Text=((Label)e.Item.FindControl("ItemTemplateLabelID")).Text.ToString();
  4. }
  5.  
Sep 18 '07 #4
Dyny
8
try this code......assuming that your button CommandName is Select

Expand|Select|Wrap|Line Numbers
  1.  if ( e.CommandName=="Select") 
  2. {
  3. Label1.Text=((Label)e.Item.FindControl("ItemTemplateLabelID")).Text.ToString();
  4. }
  5.  
Thank you for the reply...but its not working.i have given button column in the grid.here you have specified templatelabel
Sep 18 '07 #5
dip_developer
648 Expert 512MB
Thank you for the reply...but its not working.i have given button column in the grid.here you have specified templatelabel
nothing wrong with the button column.......you know that whenever a button in the grid is clicked the ItemCommand event fires......ok??? you may have many buttons in the grid....so check first what button is clicked by the commandname property.....then do your needful.....

please tell me whether there is any Template column in your grid or not???

otherwise the code I have given you is 100% OK.......
Sep 18 '07 #6
Dyny
8
nothing wrong with the button column.......you know that whenever a button in the grid is clicked the ItemCommand event fires......ok??? you may have many buttons in the grid....so check first what button is clicked by the commandname property.....then do your needful.....

please tell me whether there is any Template column in your grid or not???

otherwise the code I have given you is 100% OK.......
No I hav'nt used any template column....
Sep 18 '07 #7
Dyny
8
No I hav'nt used any template column....

if (e.CommandName == "Approve")
{
Label2.Text = e.Item.Cells[0].Text.ToString();
}


this is the code i had given....later i tried ur code..
Sep 18 '07 #8

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

Similar topics

0
by: lu | last post by:
I have a page with datagrid (for viewing, delete,edit,update) and text fields with button to add info to database. When user comes to page the datagrid selects info from database, binds in...
12
by: James Norton-Jones | last post by:
Hi, Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
0
by: Danny | last post by:
I am trying to sort my second datagrid. And it works but only after i click 2 times on the column header. The first time i click on the header the data in the right order will add to the rows in...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
6
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label...
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
1
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.