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

  • Thread starter Thread starter anonymoushamster
  • Start date Start date
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
 
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
 
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.
 
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
 
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!
 
Back
Top