Noob Question sorry!

Don
Joined
5 Oct 2005
Posts
11,239
Location
Liverpool
How do I get this line to insert the number??

int PriKey = (AdminGridView.Rows[e.RowIndex].Cells[0]).insert here;

I can't for the life of me do this, for example if I wanted text I would put...

string PriKey = (AdminGridView.Rows[e.RowIndex].Cells[0]).Text;

Stelly

p.s. sorry sorry sorry
 
Try This:
Code:
int PriKey = int.Parse(this.AdminGridView.Rows[e.RowIndex].Cells[0].Value);
TrUz
 
TrUz said:
Try This:
Code:
int PriKey = int.Parse(this.AdminGridView.Rows[e.RowIndex].Cells[0].Value);
TrUz

not there I mean this...

'System.Web.UI.WebControls.TableCell' does not contain a definition for 'Value'

Stelly
 
protected void AdminGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int PriKey = int.Parse(this.AdminGridView.Rows[e.RowIndex].Cells[0].value);

SQLQueries.InsertDeleteLog(PriKey, TimeStamp, UserName, BookedFrom, accessed);
}

like this... and I know its not finished :)

Stelly
 
Ahhh Web Application, sorry try this:
Code:
int i = int.Parse(this.GridView1.Rows[e.RowIndex].Cells[0].Text);
TrUz
 
Hmmm, does for me. What error are you getting now? What kind of Data is in the grid?

TrUz
 
TrUz said:
Hmmm, does for me. What error are you getting now? What kind of Data is in the grid?

TrUz

what you mean?? few integers and strings thats about it... I cant see anything wrong with it to be honest... help :)

Stelly
 
Do you have the Edit, Delete and Select buttons on your Grid? If so the Cell index is going to be 1 not 0.

I have just tested with this and it is fine.
Code:
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int i = int.Parse(this.GridView1.Rows[e.RowIndex].Cells[1].Text);

            Console.Write(i.ToString());
        }
EDIT: Might be worth using row deleted. Just incase there is a problem deleting the row you will fill your delete log with false deletes.

TrUz
 
TrUz said:
Do you have the Edit, Delete and Select buttons on your Grid? If so the Cell index is going to be 1 not 0.

I have just tested with this and it is fine.
Code:
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int i = int.Parse(this.GridView1.Rows[e.RowIndex].Cells[1].Text);

            Console.Write(i.ToString());
        }
EDIT: Might be worth using row deleted. Just incase there is a problem deleting the row you will fill your delete log with false deletes.

TrUz

are you sure?? if so oops.. I mean they are on the end of the data row though

Stelly
 
My Edit, Delete items etc... was in the first column. If it is the first column (0) that has you item then I am not sure why it is not working.

TrUz
 
Back
Top Bottom