Helloo friend.
i m facing problem in GridView1_SelectedIndexChanging.
i have grid view it contains data . now i want that when user press select button. then complete details data show in detail view control of the particular dataID.
i use templates in grid view.,
PersonalAddBookBE objPersonalBE = new PersonalAddBookBE();
objPersonalBE.PersonalInfoId =Convert.ToInt32(GridView1.Rows[e.NewSelectedIndex].Cells[1].Text);
PersonalAddBookBL objPersonalBL = new PersonalAddBookBL();
DataSet ds = new DataSet();
ds = objPersonalBL.SelectAllPersonalAddBook(objPersonalBE);
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
i m doing this and error comes in this line?
objPersonalBE.PersonalInfoId
=Convert.ToInt32(GridView1.Rows[e.NewSelectedIndex].Cells[1].Text);
(Description:
An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.FormatException: Input
string was not in a correct format.
)
can anyone tell me how to assign row so tht function take in give complete detail in detailview.
i m using templates field in GV nd its n tire project
Thanks in advance
Loading
Sam HobbsPosted Apr 19, 2010, 3:39 PM
Amit ChoudharyPosted Apr 19, 2010, 10:48 AM
Try below code..
void CustomersGridView_SelectedIndexChanging(Object sender, GridViewSelectEventArgs e)
{
GridViewRow row = CustomersGridView.Rows[e.NewSelectedIndex];
if (row.Cells[1].Text == "ReadOnlyCellText")
{
e.Cancel = true;
MessageLabel.Text = "You cannot select " + row.Cells[2].Text + ".";
}
}
Please mark as answer if it helps.
Raghvendr SinghPosted Apr 19, 2010, 8:36 AM