Adding a record to SqlDataSource through GridView

J

jecker01

Hi,

I have written this method to add a blank record in edit state to GridView
upon the button press event:

protected void btnAdd_Click(object sender, EventArgs e)
{
GridViewRow newRow = GridView1.CreateRow(0, 0, 1, 2);
DataBind();
}

I am getting an error that CreateRow method is inaccessible due to its
protection level. Also, I am not sure if those parameters to CreateRow are
correct, and I don't know what to do with the GridViewRow object it returns.
To explain my choice of parameters:

0 - for 0th row index
0 - for 0th datasource index (i'm only using one datasource....not sure what
is needed here)
1 - i need the added row to be a data row...i thought based on the bitwise
enumeration quality of this parameter, i should put 1 to indicate data
row...does this need to be changed?
2 - i need the row added to be in edit state...chose 2 using the same logic
as the last param...not sure if it's correct

Please help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top