I need help to select information from a gridview not to delete, I´ve seen multiple ways to delete and I've tried to adapt it to my code but I'm having some issues with it, Im using a session state to pass the values of the row through a class, so when
I get to the second webform I cant find a way to save show the information in an independent way.
In my backend I have the code that fills the gridview which is working perfectly, also the code that evaluates if the checkbox has been checked, this is the code of my button that stores the value of the row and sends it through the session
You could loop through and read the values accordingly like below
if (Session["Application1_Data"] != null)
{
List<Expedientes> polizas = Session["Polizas"] as List<Expedientes>;
if (polizas != null)
{
if (polizas.Count > 1)
{
foreach (Expedientes exped in polizas)
{
//Assign value to controls here
TextBox1.Text = exped.poliza.ToString();
//Add other controls here
}
}
else
{
//If its single item then you can directly access the record
//Assign value to controls here
TextBox1.Text = exped[0].poliza.ToString();
//Add other controls here
}
}
}
I can access the information with the foreach statement! I just have one issue remaining and it is that I get only 1 row of all the grid view selected, if more than 1 row is selected a don't really know how to display the diferent rows because they could
be 5 or 6 or more
foreach (Expedientes exped in polizas)
{
//Assign value to controls here
Label1.Text = exped.poliza.ToString();
Label2.Text = exped.ramo.ToString();
Label3.Text = exped.nomrmo.ToString();
Label4.Text = exped.nomcia.ToString();
Label5.Text = exped.rif.ToString();
Label6.Text = exped.cct.ToString();
Label7.Text = exped.certif.ToString();
Label8.Text = exped.compa.ToString();
//Add other controls here
}
it is that I get only 1 row of all the grid view selected, if more than 1 row is selected a don't really know how to display the diferent rows because they could be 5 or 6 or more
You are seeiing one row because the values keep getting overwritten on every loop and you will see only the last values in textbox controls. If you have multiple values the best option is to use a gridview with Textbox on EditItemTemplate and assign the
value to textbox.
You can also add textbox or label controls dynamically, but best option is to you data binding control like repeater which does give custom html layout.
Member
2 Points
11 Posts
Select complete rows from a gridview using a checkbox and transfer to another webform
Jan 27, 2017 09:20 PM|hanspam|LINK
I need help to select information from a gridview not to delete, I´ve seen multiple ways to delete and I've tried to adapt it to my code but I'm having some issues with it, Im using a session state to pass the values of the row through a class, so when I get to the second webform I cant find a way to save show the information in an independent way.
This is my gridview code
In my backend I have the code that fills the gridview which is working perfectly, also the code that evaluates if the checkbox has been checked, this is the code of my button that stores the value of the row and sends it through the session
The issue is to retrieve the value of the class from the second webform, because I want to handle each row with a separate variable.
What do I need to put in the page load of webform2 apart from this
Regards, and thanks
All-Star
50841 Points
9895 Posts
Re: Select complete rows from a gridview using a checkbox and transfer to another webform
Jan 27, 2017 09:58 PM|A2H|LINK
You could loop through and read the values accordingly like below
Aje
My Blog | Dotnet Funda
Member
2 Points
11 Posts
Re: Select complete rows from a gridview using a checkbox and transfer to another webform
Jan 30, 2017 01:17 PM|hanspam|LINK
Wow, thanks!
I can access the information with the foreach statement! I just have one issue remaining and it is that I get only 1 row of all the grid view selected, if more than 1 row is selected a don't really know how to display the diferent rows because they could be 5 or 6 or more
All-Star
50841 Points
9895 Posts
Re: Select complete rows from a gridview using a checkbox and transfer to another webform
Jan 30, 2017 05:13 PM|A2H|LINK
You are seeiing one row because the values keep getting overwritten on every loop and you will see only the last values in textbox controls. If you have multiple values the best option is to use a gridview with Textbox on EditItemTemplate and assign the value to textbox.
You also need to set the gridview to edit mode be default. Refer this link for doing that : http://highoncoding.com/Articles/219_GridView_All_Rows_in_Edit_Mode.aspx
Aje
My Blog | Dotnet Funda
Member
260 Points
138 Posts
Re: Select complete rows from a gridview using a checkbox and transfer to another webform
Jan 30, 2017 05:24 PM|mohtshm|LINK
You can also add textbox or label controls dynamically, but best option is to you data binding control like repeater which does give custom html layout.
https://pk.linkedin.com/in/mohtishamzubair