473,394 Members | 1,702 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,394 software developers and data experts.

how to programatically call a gridview event from codebehind.

69
hi guys,

I have 2 gridviews, one inside a modal popup(gvSuppliers) and one on the page(gvFirms). The header row of the gvFirms has 4 text boxes. I can find those controls easily inside the selectedindexChanged method of gvSuppliers easilly when one row gvSupliers is selected. My problem arises when i try to find the 4 textboxes inside the emptydatatemplate of gvFirms.

Eg.

Expand|Select|Wrap|Line Numbers
  1. protected void gvSuppliers_SelectedIndexChanged(object sender, EventArgs e)
  2.     {
  3.         GridViewRow row = gvSuppliers.SelectedRow;
  4.         LinkButton linkbutton = (LinkButton)row.Cells[0].FindControl("LinkButton1");
  5.         TextBox SupplierID = (TextBox)gvFirms.HeaderRow.FindControl("txtNewSupplierId");//This is the first textbox
  6. }
  7.  
My question is, inside gvSuppliers_SelectedIndexChanged method, how do i find the textboxes inside the emptydatatemplate of gvFirms.

one thought that crossed my mind was to programatically call the rowcommand event within the gvSuppliers_SelectedIndexChanged method and so i should have the GridViewCommandEventArgs e and then i could say something to this effect inside gvFirms_Rowcommand method

Expand|Select|Wrap|Line Numbers
  1.  if (e.CommandName.Equals("AddNewItem"))
  2.             {
  3.                 GridViewRow row = (GridViewRow)((e.CommandSource as Button).NamingContainer);
  4.  
  5.                 string categoryName = (row.FindControl("txtCategoryName") as TextBox).Text;
  6.  
  7.  
I dont know what to do
Please help asap
Aug 25 '08 #1
3 2742
PRR
750 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. if (e.CommandName.Equals("AddNewItem"))
  2.             {
  3.                 GridViewRow row = (GridViewRow)((e.CommandSource as Button).NamingContainer);
  4.  
  5.                 string categoryName = (row.FindControl("txtCategoryName") as TextBox).Text;
  6.  
  7. Example :
  8. CheckBox  cblogin = ( CheckBox) gr.FindControl ("chkLogin");
  9.  
  10. if(cblogin.checked)
  11. {
  12.  
  13. }
  14. Textbox t=(TextBox)gr.FindControl ("Textbox1");
  15.  
  16. string ss=t.text;
  17.  
or this may work ...
Expand|Select|Wrap|Line Numbers
  1.  string categoryName = (row.FindControl("txtCategoryName") as TextBox).value ;// i dont recollect fully....
i dont think i asnwered your question correctly... can you explain further....
From what i understand.. i guess u will have to loop through all controls in gridview2 .... in case that is accessible to the original page..which i think is not?.
Sep 2 '08 #2
Curtis Rutland
3,256 Expert 2GB
dirtbag,
Please use code tags when posting code. It makes it easier for everyone to read. Also, it's part of the rules.

MODERATOR
Sep 2 '08 #3
PRR
750 Expert 512MB
dirtbag,
Please use code tags when posting code. It makes it easier for everyone to read. Also, it's part of the rules.

MODERATOR
ok i keep that in mind... thanks
Sep 4 '08 #4

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

Similar topics

4
by: ber.janssens | last post by:
Hi, In ASP.NET 2.0, I have a GridView with 2 CommandFields, how can I determine in the SelectedIndexChanged event which CommandField is clicked? <asp:GridView ID="gvOrderList" runat="server"...
3
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create...
9
by: J055 | last post by:
Hi I have a very simple configuration of the GridView with paging and sorting. When I do a postback the DataBinding event fires twice - in both the ProcessPostData and PreRender stages of the...
1
by: Nam | last post by:
I have a DropDownList control in a TemplateField inside my GridView How do I access this control’s SelectedIndexChanged event in codeBehind page? I don’t see the ID “DropDownList1” of...
0
by: dawg1998 | last post by:
I am able to populate a DropDownList control within multiple rows of a GridView with the following code: `````````````````````````````````````````````````````` <asp:GridView id="gvGridView"...
0
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
13
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The...
9
by: RobertTheProgrammer | last post by:
Hi folks, I've been struggling with this for a few hours and I'm hoping someone can help me out. On my GridView (with C# codebehind) I have a date entry field. To help users enter only valid...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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...
0
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
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...

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.