Find grid control inside grid without its rowbound event - c#

I have a grid of list of companies & below its branches(subgrid within company grid). I have checkbox for each binding with their id's(Companyid & branchid).I have one button to add those selcted values from either company or branch & show all selected record in another grid.Add button is outside of gridview so on click of add button i have to find branch gridview here i can find its parent grid.I wrote following code to find control inside onclick event of add button but its not finding that control:
GridView gvbranch= (GridView)gvcompany.FindControl("gvbranch");
So please help me how i can find that child control in add click event?
Thanks

foreach (GridViewRow row in gv.Rows)
{
TextBox txt = row.Cells[0].Controls[0].FindControl("TextBox1") as TextBox;
string value = txt.Text;
Response.Write(value);
}
use something like this , on button event

Related

how to get the rows if textbox value has changed inside gridview

After editing the textbox values inside this gridview, i need to get the rows (only edited rows) in button click event (button placed outside the gridview).
Add event listener on the gridview to grab the selected items value on change, and add them to an array. Loop through to use the data.

Telerik gridview for winforms selected row type

I am using Telerik gridview in a winform application. When I click on the row the control goes to another page with some data. I am using grid views click event to pass the control to another form. But even when you click on header column or pager row it is going to the next form with data selected from the first row. What is the way to figure out the type of row. Whether it is a datarow or a header row?
private void grdGuests_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(this.grdGuests.CurrentRow.Cells[1].Value.ToString());
GuestDetails gd = new GuestDetails(id);
gd.Show();
}
I even tried to use MouseClick but its the same thing if I click on next page button or header row it takes it as a grid click event and pass the control to next page.
You can use the CurrentRowChanged event and check if the row type is GridViewDataRow info, so you avoid non-data rows.

How to pass selected list value from popup into a textbox using C# webforms?

I have a table called Vendor that has two columns: VendorNum & VendorName.
Is there a way to create a list or a listbox or a listview that when a button is clicked, this vendor list will pop up. Then the selected popup list's row will pass the selected VendorNum into a textbox that's in the parent page..
I only know GridView has the select row option, but is it a proper way to put the gridview into a Listbox so the list can be scrolled up/down all within a fixed box?
You might want to take a look at the ListBox.SelectValue and/or ListBox.SelectedItem properties

Nested gridview get outer gridview row index on inner gridview footer button click

I have a nested gridview with a add button in the footer of one column and a textbox in the footer of another column. When I click the add button, it would add a row into the nested gridview with the value that was entered in the textbox. I am trying to figure out how to get the row index of the outer gridview in the add button click function.
Or is there a better way to accomplish what I have described above in general?
In the onclick event do:
//Button Row //GridView //Parent row
var parentRow = (GridViewRow)sender.NamingContainer.NamingContainer.NamingContainer;
var index = parentRow.RowIndex;

DevExpress XtraGrid - Cannot select Master Row

I have a gridView with a 1to1 master-detail relationship for each master row. When a user clicks on the detail view I want to make sure that the master row is also activated (has the activated icon in the very left column):
This works fine if I navigate the master and detail grids with the keyboard, but doesn't work with the mouse. So I wrote to following code to try and fix this, but it doesn't work. This code is triggered via the detail view's click event:
GridView focusedView = gridView3.GridControl.FocusedView as GridView;
// get the currently selected row in the child view
int focusedRowHandle = focusedView.FocusedRowHandle;
// get the parentView's row handle that owns the child view
int sourceRowHandle = focusedView.SourceRowHandle;
GridView parentView = focusedView.ParentView as GridView;
parentView.BeginSelection();
parentView.SelectRow(sourceRowHandle);
parentView.EndSelection();
Can anyone let me know what I am doing wrong?
Are you using the Single Row selection mode? If multiple selection is disabled (the ColumnViewOptionsSelection.MultiSelect option is set to false) the SelectRow method does nothing.
Use the ColumnView.FocusedRowHandle property to select the master row that owns the detail View.
Related article: Selection Overview

Categories

Resources