hey everyone
I am using a grid and template form for editing grid items.I have created a panel for editing items that is visible on external button btnEdit_Click.tha problem is with my code when i select a row and click on edit,i am trying to get the id of the row been selected.But its giving error-
my primary key column is UID.
Thanks
Amit
I am using a grid and template form for editing grid items.I have created a panel for editing items that is visible on external button btnEdit_Click.tha problem is with my code when i select a row and click on edit,i am trying to get the id of the row been selected.But its giving error-
Object reference not set to an instance of an object.
my code is--protected
void
btnEdit_Click(
object
sender, EventArgs e)
{
if
(RadGrid1.SelectedItems.Count != 0)
{
//Guid g = new Guid(txtName.Text);
txtName.Focus();
pnlExternalForm.Visible =
true
;
RadGrid Grid = (
this
.FindControl(
"RadGrid1"
)
as
RadGrid);
string
UID = Convert.ToString(Grid.SelectedValues[
"UID"
]);//this shows no row is selected
string
query =
"SELECT * FROM Entry where UID="
+ UID;
GetProductInfoForEdit(query, UID);
LoadData();
}
}
private
void
GetProductInfoForEdit(
string
query,
string
UserID)
{
DataSet ds = GetInventoryForm(query);
txtName.Text = Convert.ToString(ds.Tables[0].Rows[0][
"Name"
]);
txtMailText.Text = Convert.ToString(ds.Tables[0].Rows[0][
"Mail Text"
]);
txtMailSubject.Text = Convert.ToString(ds.Tables[0].Rows[0][
"Mail Subject"
]);
lblUID.Text = UserID;
LoadData();
}
Thanks
Amit