I've got a Gridview that lists some SQL data.
And i've got a Formview setup with edit template.
I then want a LinkButton in Gridview, to open edit in formview, with the selected entry in gridview.
I've got this to capture my edit command from Gridview, but how i then trigger my Formview i dont know?
public void newsEdit_Command(Object sender, CommandEventArgs e) {
//Trigger formview edit from here...
//e.CommandArgument contains my ID of the selected row in gridview.
}
In the way you want, i think it is not possible.
You can do it in a simple way as:
1) Show Data in a grid view, When a user selects a row in the grid view, show that row data in the form view ( or you can use a details view )
2) After displaying data in form view, Now edit it's row.
Related
I have a grid view which display all of my saved data. When I click on date search button, data bind in grid view of particular date that I typed in text box. But when I try to go next page by clicking grid view pager button, grid view date bind all page of saved date. It's not binding data of that particular date. Please help me...
you can implement PageIndexChanging as below.
protected void GridViewExtUsers1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
// Set the index of the new display page.
GridView1.PageIndex = e.NewPageIndex;
// Rebind the GridView control
// if on search mode bind search results
// otherwise bind all data.
// implement your logic in different method
BindGridView();
}
My GridView is loaded with data from my database in a DataSet, which corresponds to Labels inside the GridView.
When users click the Select button on a GridViewRow, the button fills a TextBox outside the GridView from the selected row's column value.
After editing values in the TextBox outside my GridView, the user can click a button to move the new value from the TextBox back to the GridView (but not to the database).
My problem is: when I select the next row and do the same action, it clear the previous newly-added row data. It doesn't retain the previous row data.
I know it can be done by ViewState or Session, but it didn't work for me.
check for if(! ispostback) before filling data back to your grid. i am assuming that on click of select (Edit) button your page post back and then it fills value in textbox for edit and same time its refilling data in grid control also. so before filling value in grid control make sure its not postback.
I am having a gridview control and in the edit template of the gridview control., inside the edit template I need another grid view control., I am having a bound field in the second gridview which always binds to the selected value in the gridview 1 .,
So can somebody tell me in which event and all i have to do the databind for the gridview 2.
I am having an sqldatasource for the gridview2.
Thanks
i think the event you are looking for is "row_command" of your main gridview. in row_command event, you can get your value from the row that you selected, then find your gridview inside your row, and give its datasource.
i cant test it now, but should be something like this
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = MainGridView.Rows[index];
Gridview dv = row.FindControl(“yourGridViewId”);
dv.DataSource = yourdatasource;
Suppose I have a e-shop web app. I have a product categories table in my database that populates a gridview using sqldatasource.
I want to be able to click on the select hyperlink on a row and use that event to populate ANOTHER gridview based on the ID of the product category that is clicked. E.g say the 'CDs' row is clicked, another gridview shows all the different CDs.
As a result, I need the select(sql) statement for the second table to be dynamic based on what the user clicks.
Has anyone done anything like this before?
Any help would be greatly appreciated,
Mark
It should be very easy. The key is to use SelectedValue of first Gridview to be used as a parameter to the query to populate second gridview.
Here is a sample: Master/Detail GridView
The sample show GV and DetailsView but in your case you replace DV with another GV.
Currently i have a datagrid view that displays names in the 1st columnnd in the 2nd column delete buttons.
This datagrid view already has bind data to a function so it can displays the names that are withint a xml file (first column is a hyperlink column).
But next i want to be able to delete the xml values that are in the first column.
(by clicking on the delete button on the second column of it)
<name></name>
But how do i exactly bind a (delete) function to these buttons?
name1 btnDelete
name2 btnDelete
etc...
Thanks in advance.
For datagrid you have handle the ondeletecommand event, see below.
<asp:DataGrid runat="server" ID="dg" ondeletecommand="dg_DeleteCommand">
then define the event handler in your code behind .. see below.
protected void dg_DeleteCommand(object source, DataGridCommandEventArgs e)
{
}
the DataGridCommandEventArgs has all the properties you'll need to check including e.CommandName etc
Hope this helps.
I don't know about datagrid but in gridView I use
set button's command name and use GridView's RowCommand Event.
if(e.commandName == "delete")
//ur code;
Template field
for default delete of GridView use
girdViewRowDeleting
Hope it will help..