Having terrible time replacing a textbox in a gridview with another type in edit mode

A

anonymoushamster

Whether it is a checkbox to be replcaed with and image or a textbox to
be repalced with a dropdown, imfailing.

One simple reason. I can add a new compoentn into the edit row ,I
jsut cant replace an existing one or fin done to then set it to
invisible.

Any help, greatly appreciated.

Many thanks,
hamsters
 
A

anonymoushamster

Sorry anonymous, please forgive my terrible spelling.

Just to make it clear.

I want replace the edit row which displays data in textboxes to
display the dat aas dropdowns. I can add dropdowns but I cant remove
the textboxes and I am not sure how to refer them.

How should I go about solving this?

Thanks again,
hamsters
 
G

GaiaMH

Sorry anonymous, please forgive my terrible spelling.

Just to make it clear.

I want replace the edit row which displays data in textboxes to
display the dat aas dropdowns. I can add dropdowns but I cant remove
the textboxes and I am not sure how to refer them.

How should I go about solving this?

Thanks again,
hamsters

You can use the OnRowEditing event of the gridview to specify you own
event handler :

<asp:GridView ID="GridView1" runat="server" ...
OnRowEditing="editRow" />

In your code you add an event handling method :

protected void editRow(object sender, GridViewEditEventArgs e)
{
e.Cancel = true;
GridView1.Rows[e.NewEditIndex].Cells[0].Text = "Changed";
}

e.Cancel = true; will disable the event and asp.net won't add the
textbox.
e.NewEditIndex is the row index of the selected row.
From there you can call your code to generate the dropdown list, I'm
not sure how the RowUpdating event will be affected by this, but you
can always custom handle that also.
 
H

hamsterchaos

Sorry anonymous, please forgive my terrible spelling.

Just to make it clear.

I want replace the edit row which displays data in textboxes to
display the dat aas dropdowns. I can add dropdowns but I cant remove
the textboxes and I am not sure how to refer them.

How should I go about solving this?

Thanks again,
hamsters

autogenerate columns must be off - sorted
 
H

hamsterchaos

Sorry anonymous, please forgive my terrible spelling.
Just to make it clear.
I want replace the edit row which displays data in textboxes to
display the dat aas dropdowns. I can add dropdowns but I cant remove
the textboxes and I am not sure how to refer them.
How should I go about solving this?
Thanks again,
hamsters

You can use the OnRowEditing event of the gridview to specify you own
event handler :

<asp:GridView ID="GridView1" runat="server" ...
OnRowEditing="editRow" />

In your code you add an event handling method :

protected void editRow(object sender, GridViewEditEventArgs e)
{
e.Cancel = true;
GridView1.Rows[e.NewEditIndex].Cells[0].Text = "Changed";
}

e.Cancel = true; will disable the event and asp.net won't add the
textbox.
e.NewEditIndex is the row index of the selected row.
From there you can call your code to generate the dropdown list, I'm

not sure how the RowUpdating event will be affected by this, but you
can always custom handle that also.

actually htis is a far superior solution - thank you very much!
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top