can we find control of itemtemplate in updatecommandeventargs of datagrid after clicking edit button in the datagrid?

hi im having a editable datagrid here in one column of template field im having a label control in itemtemplate and a textbox control in edititemtemplate.now i want to find the label control in update command eventargs ...is this possible here im able to find the control of edititemplate but im unable to find the control of itemplate .


pavankumar
0
pavankumarkavety
5/31/2008 5:31:13 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
681 Views

Similar Articles

[PageSpeed] 41

In any event, you can find controls in itemtemplate.

for(int vLoop=0 ; vLoop<gv1.rows.count ; vLoop++)

{

    Label lbl = (Label)gv1.rows[vLoop].findcontrol("lblID");

}


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
5/31/2008 7:39:28 AM

thnx for the reply i ve tried doing like this when im updating data in the grid

i was able to find control of edititemtemplate but unable to find control of itemtemplate of that column

//finding the label in datagrid and getting the id.

Label RangeId = (Label)e.Item.FindControl("lblRangeId");

TextBox From = (TextBox)e.Item.FindControl("txtFrom");

TextBox To = (TextBox)e.Item.FindControl("txtTo");

TextBox Price = (TextBox)e.Item.FindControl("txtPrice");

//Label lFrom = (Label)e.Item.FindControl("lblFrom");

//Label lTo = (Label)e.Item.FindControl("lblTo");

//Label lPrice = (Label)e.Item.FindControl("lblPrice");

//updating the values in the database.

SqlHelper.ExecuteNonQuery(trans, CommandType.Text,

"Update tPrintServiceRange set [From]='" + From.Text + "',[To]='" + To.Text + "',Price='" + Price.Text + "' where RangeId=" + RangeId.Text);

//lFrom.Text = From.Text;

//lTo.Text = To.Text;

//lPrice.Text = Price.Text;

//getting datagrid to normal position.

grdvwRange.EditItemIndex = -1;

lblMessage.Text =
"Data Updated Sucessfully.";lblMessage.ForeColor = System.Drawing.Color.Green;

trans.Commit();

here is da code


pavankumar
0
pavankumarkavety
5/31/2008 7:46:36 AM

You are trying  findcontrol() method in rowupdating event. in that situation, there will be only edititemtemplate. but not itemtemplate.

what i would suggest is in edititemtemplate also, place a label. and assign rangeid to that label.

<ediitemtemplate>

             <asp:Label Id="lbleditId" Text='<%  #Bind("rangeId") %>' runat="server"

</ediitemtemplate>


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
5/31/2008 8:00:03 AM

 

ya even if i place a labe in edititemtemplate i can bind to the edititemtemplate control but not to the control in the itemtemplate ...

 


pavankumar
0
pavankumarkavety
5/31/2008 8:33:28 AM
Reply:

Similar Artilces:

How to place a DataGrid Control with in a DataGrid Control
Hi, I want to place a DataGrid control in a DataGrid control can any one plz tell me the procedure to place the control Thanks in Advance Krisamigo <!---<asp:DataGrid ID=dg_List runat=server><Columns><asp:TemplateColumn><ItemTemplate><asp:DataGrid ID=dg_List2 Runat=server></asp:DataGrid> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> ---> Hardik Joshi...

Can you have a datagrid control inside of a repeater control. If so, how do you reference the datagrid in code behind
Hello, If anyone can help, it would be greatly appreciated. I have a repeater control and I want to place a datagrid inside of the repeater control's item template. The problem is, I don't know how to reference the datagrid control in the code behind. Also, can I bind data into the headertemplate of the repeater control such as a name. Actually I would only need a name. Don't know about GridView inside the Repeater, but did you thought about Repeater inside the Repeater?(Example below)  1 Protected Sub rptMain_ItemDataBound(ByVal sender As Object, ByVal e As Syst...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

EditItemTemplate control = ItemTemplate control
Hi Friends! I have a CheckBoxList inside a DataGrid template column (ItemTemplate). When ItemDataBound event is raised, this CheckBoxList is populated. As follow bellow: Private Sub grdUsuarios_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdUsuarios.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim chlFilaisUsuariosDGRow As CheckBoxList = e.Item.FindControl("chlFiliaisUsuario_EditItem") chlFilaisUsuariosDGRow...

Finding controls in datagrid in user control
Hi, here's the scenario. I had a datagrid in a page, worked fine. I've moved the datagrid to a user control, and the update code I had does not work anymore.   In the datagrid, I have: OnUpdateCommand="update_user"   In the class for the user control, I have:   Protected Sub update_user(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)   then later, as part of a loop that cycles through the field names - data_field(x):   Dim drop_down As DropDownList = CType(e.Item.FindControl(data_field(x)), DropDownList)sql_comm.parameters.add("@" & data_...

Find Button Control in datagrid
i have a grid with 3 coulmns the first column is a label second is a template column with the textboxes. the third is the template column with asp:button. Now when i click on the button there is a common javascript function that is called by onclick of the button what i want is the clientId of the aspbutton at the servercode this is what i am doing? Dim grditem As System.Web.UI.WebControls.DataGridItem For Each grditem In grdprog.Items Dim btnpopup As System.Web.UI.HtmlControls.HtmlInputButton = grditem.FindControl("btnCategory") Dim btnID As...

which button on a DataGrid web control is clicked?
I have 3 buttons in each row of my DataGrid(asp.net/vb.net); I know which row the user clicked from (e.Item.ItemIndex) however I do not know which button they clicked? How can I find out which button user clicked?. Thanks in advance,Sam Dalil     You have to set the command name of the button. then just check which command name was clicked to know which button was hit. Where you're getting the information for the row is from SelectedIndexChanged.  What you should prob look at is OnClick event handling for each of the buttons. While there are mi...

How can I use ItemTemplate inside of DataGrid control?
I was looking through my asp.net book (pretty new to .net) and got this code that will make a data list from the database, and build it according to the template design (code below)<asp:datalist  ID="dlstAuthors"  DataKeyField="au_id"  OnEditCommand="dlstAuthors_EditCommand"  OnCancelCommand="dlstAuthors_CancelCommand"  OnDeleteCommand="dlstAuthors_DeleteCommand"  OnUpdateCommand="dlstAuthors_UpdateCommand"  RepeatColumns="4"  GridLines="Both"  CellPadding="10"  EditItemStyle-BackColor="lightgrey"  Runat="Server"> <ItemTemplate...

DataGrid
 Below you will fine my complete source coude, I dont seem to understand why its not updateing the Entry_Order, anyone that can help me with this I'd appreciate it. Entry_Order, and UserId/PIN number is what I am trying make updateable. As of right now the edit works on USERID.    1 using System; 2 using System.Collections; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Web; 7 using System.Web.SessionState; 8 using System.Web.UI; 9 using System.Web.UI.WebControls; 10 using System.Web....

datagrid control in to Tabstrip control .
i need to insert a datagrid in a tabstrip seperator. is this possible? and in what way . Do you really mean Tabstrip "Seperator"? Or are you just trying to insert a DataGrid into a TabStrip control? ...

datagrid inherited control with datagrid
Hi, I want a control which has all the features of the datagrid control. So I Inherit from the datagrid control and get all the features. But now I also want to add two buttons with the same control. How can I do that ? Since the my control is inherited from datagrid and not from webControl class. Thanks,HighOnCodingWanna get high! ...

DataGrid and Controls within DataGrid
Ok, so I am totally beat  .  Noone was able to reply to my last topic regarding the complications I was running into with creating a DataGrid programmatically. (If curious, please find the last thread I created).  This is what I need to do: Page loads values into dropdownlist.  User selects a grade from this ddl.  Code takes value, queries the db, stores result in a datatable, dt.  Cool.  Now we bind data from this dt to the DataGrid, dgDataGrid.  The two items the db returns are 'Item Name' and 'Quantity'.  Please keep in mind ...

Control No of records in DataGrid control
Hi I am having more than 5000 records in the table. I had set page size:50, its loading 5000 records and showing 50 records... working fine. But my requirement is when page is loading i need to get only 50 letest records from the database. If user clicks on next it need to be connected to database and get next 50 records. How i can put pointer at 50 th record? Is there any way to do this???... plz help Top function wont work for me. Hope the problem is clear regards cnu The SQLDataAdapter can limit the rowsets in one of the Fill() method overloads. Check it out in the ...

Clearing selection in DataGrid when user clicks outside the DataGrid control (Windows Forms)
Dear All, What is the best way to clear selection in the DataGrid/DataGridView when the user clicks outside the control? For example, user clicks inside the DataGridView, selects entire row, then clicks outside the DataGridView to clear the selection.  What events can I monitor, and what is the best approach to solving this problem? Any feedback would be appreciated, this seems to be very difficult to do.   Thanks....

Web resources about - can we find control of itemtemplate in updatecommandeventargs of datagrid after clicking edit button in the datagrid? - asp.net.presentation-controls

Resources last updated: 11/30/2015 8:53:23 PM