Get Label text from Label in Gridview

 Hi all!

I have a serious problem. When I swirch to editing mode for a row, I should get on of the value of this row, but I don't, how can I solve it.

Can anybody help? (prfer code)



8/30/2007 9:15:05 AM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

can u give ur grid html?



Best is Not the END point, but a starting point for Innovation
Remember to mark posts as the "Answer" to help future users.
8/30/2007 11:29:53 AM


  I wrote some code here:

  protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        Label l = GridView1.Rows[e.NewEditIndex].FindControl("Label2") as Label;

 <asp:GridView AutoGenerateEditButton="True" ID="GridView1" runat="server" DataSourceID="SqlDataSource1" OnPreRender="GridView1_PreRender" OnRowEditing="GridView1_RowEditing">
            <asp:Label ID="Label2" runat="server" Text='<%#Eval("theID") %>'></asp:Label>

  If it doesn't work, please inform us.


Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
9/5/2007 5:52:11 AM

 Hi, thanks

 It's working. My problem was, that I cannot implement it into a syntax, but I successfully solved it with:


        Dim LBLo As Label = New Label
        LBLo = CType(GridView1.Rows(GridView1.EditIndex).Cells(4).FindControl("Label2"), Label)


9/5/2007 12:44:30 PM

Similar Artilces:

Justify label text in .net(dynamic label)
 Hi all,        I am working on I am creating my lable as dynamic. Justify the text is not coming in "Mozilla" but coming in "IE".I am applying style to lable as l1.Style.Add("TEXT-ALIGN", "justify")For static label is working. my code for static label<div style="TEXT-ALIGN:justify"><asp:label id="lbl_desc" runat="server" CssClass="contents" Width="99%"></asp:label></div> ...

getting a Label control to render a <label> tag
How come the Label control doesn't produce an html <label> tag in the rendered code?  I am using FormView to create a form and I am trying to make it accessible.  Any advice is welcome.   It does render as a <label> tag if you set it's AssociatedControlID property.-wili...

Getting the label text for each control on a form
Hello all, I am working on a generic form submitter/parser/mailer. What I would like to do is iterate through each control on the form, and get the text of its associated label. With HTML, I can do something like this:<label for="name">Your Name:</label> <input type="text" id="name" size="30" />  This associates the label with the textbox. Is there a way with ASP.NET to get the label text of an associated input control? (geez.. I hope I am making sense)To use the HTML example above - I would be iterating through each input control. When I reached the textb...

Get set label text of gridview
Hi, I have a table for a classes (school) which contains the ID of other table (department). But I want to show the next column of the department table where I keep the name of department. So I have to set the label in the Item Template. I can handle this problem by making view in the database, but then I made a DropDown in the Edit Template which shows the Department names. so I have to get the SelectedIndex of the DropDown but I cannot find the tools which I insert in to Templates, if you have any idea please help.Üsame F. Esendir | I found what I wanted to do but still I wo...

how to get gridview value as label text?
hi, I'm trying to get the text from the gridview into a label. Below is a screen shot of it what i want to come out.So when i click select i want the text to the right of that to appear in Label4. We cannot see the screen shot that you have attached. Is that text present in some control? If it is in some control just use the FindControl property for that row and get the text value and then assign it to the label.Avi    hi,try the code below int index = Convert.ToInt32(e.CommandArgument); GridViewRow row1 = dg.Rows[index]; txtPORef.Text = ((Label)row1.FindControl...

Get text value of Label control in a Repeater
I have been searching all over for info on this but I can't seem to find any so any help would be very nice.I am just trying to get the value of a Label control that is in a Repeater.  I have been trying to use the ItemCommand event of the Repeater but I don't seem to be able to get access to the correct control.  Here is my code:order.aspx<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1" DataMember="DefaultView" OnItemCommand="Repeater1_ItemCommand"><HeaderTemplate><table><tr style="font-family:Verdana; font-size:smaller; color:White...

How to get text value of label control out of repeater?
Hi, I have a general question.I want to get the (text)value from a label control residing within a repeater control. If the linkbotton (lbDelete) is clicked the lbDelete_click handler is fired.But unfortunately it returns an empty string rather than a number that lblID shows within the repeater. What am I doing wrong ?How do I get the text value of lblID out of the repeater? Here is the code: <asp:Repeater ID="Repeater1" OnItemDatabound="repDatabind" Runat="server"><HeaderTemplate>    <table width="100%" border="0" cellspacing="1" cellpadding="1">&l...

Gridview Label Control, need to change color in label in C# code behind
Plenty of brilliant people on this site, this should be an easy one. I need assistance changing a label control property in the code behind, i.e. text color, ect. in a DataView.  I have labels I would like to be different colors if the control returns a specific value.  I get a "Object not found" null exception error and feel using .Row.FindControl I am kind of new to using code behind.  Please look at my example... .ASPX CODE<asp:GridView ID="GridView1" OnRowDataBound="GridView_RowDataBound" DataSourceID="SqlDataSource1" On...

get label control text in grid from java scirpt
 hi friends, i am using vs 2005. i have a grid in aspx page. It has two columnsfirst column has  check box controland second column has a lable control  my requirement is that if the user clicks the check box, i want the corresponsing row lable control text value. i can do this in server side code. But i want this in java scirpt. the moment we click the check box i want to show the corresponding lable value using java script.  How can i do this? Any help plz? thank you   i am using .net check box. but also i re...

Gridview on RowCommand i cant get itemtemplate label text??????
Hi, I have to retrieve from a gridviewrow on rowcommand a certain cell with a label... this label is in a itemtemplate! I had already used the ctype(row.findcontrol(...), label).text and the ctype(row.cell(1).controls.item(2), label).text and they both return me the value ""...If i use the row.cells(0).text on a databound the value is returning correctly... Is it because of viewstate or lack of databind at that stage? Why can i get values from databound and not from itemtemplate?   best Regards You should be able to access the text of of a label within an ItemTempl...

Iterating gridview control with javascript to get label values
I have a gridview control I need to iterate through to get some names from each row. Here is my HTML code as well as the names I need to get.<table cellspacing="0" cellpadding="2" rules="all" border="1" id="ctl00_ContentPlaceHolder1_gvAssistants" style="border-style:Solid;border-collapse:collapse;"> <tr style="background-color:DarkGray;"> <th scope="col"> </th><th scope="col">Assistants</th> </tr><tr style="white-space:nowrap;">...

Login Control
Hi I have created a login control and in its authenticate function i nam trying to change its text. But its not getting updated. When i tried changing the label text on page_load and button click its working fine. Why is it happening so?   Thanks in advance            sarika What text do you want to update? Would please paste code snippet here.Thanks Andrew ZhuMicrosoft online ASP.NET supportPlease remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread....

Text out of a formview control (label, textbox, dropdownlist) in
How would I get the text or selectedvalue out of a from view control into the subject of an email? Here is my code Dim message As New MailMessage Dim server As New SmtpClient("") Dim fromAddress As New MailAddress("") message.Subject = (Label(frmNewQCI.FindControl("P1CategoryLabel").Text)) message.Body = "New QCI Created" message.To.Add("") message.From = fromAddress server.Send(message)   It is underlining Label and saying   'Label' is a type and cannot be used as an expression.  It's also underlining the rest an...

label event? label.text changed?
 Hia event exists that occures when the text of a lable is changed?textbox got such an event.but I couldnt find it for labels my task isi got labels, if they are empty another label shows that they must be filled with text (this works trough a popup by selecting data from a gridview this popup makes an dialog return and sets the text of the label)so if all labels != null or != "" the other label(showing that the labels are required) should be invisible    Labels dsnt have OnTextChanged type any event.========================= You can check it like th...

Web resources about - Get Label text from Label in Gridview -

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012 - Upcoming stories is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 12/28/2015 2:21:47 PM