This is a migrated thread and some comments may be shown as answers.

RadGrid blanking out upon clicking on Edit

8 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahadevan
Top achievements
Rank 1
Mahadevan asked on 03 Dec 2012, 08:17 PM
I have a RadGrid which is populated with data and when I click on edit, the whole grid blanks out

The current situation is this: I have a list box which has about 20 items, Upon selection on 1 item from the list box, the RadGrid will be populated with data and this whole process happens on the server side as I have programmed in a way where the code will look into the correct table and extract the information and populate them in the radgrid. But now i am facing challenges with the Edit functionality where the whole grid is blanking out. If i select another item from the list box, the radgrid populated back but this time, there are editable fields where i can edit. Any ideas on how i can fix this?

Thanks,
Swamy

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Dec 2012, 04:11 AM
Hi,

I am not quite sure how you are binding the grid. In order to implement advanced features in RadGrid like editing, make sure that the grid is binded with advanced data binding using its NeedDataSource event. Hope this helps.

Thanks,
Shinu.
0
Mahadevan
Top achievements
Rank 1
answered on 04 Dec 2012, 04:49 PM
Thanks for the tip. Reading that article helped me a lot :)
0
Mahadevan
Top achievements
Rank 1
answered on 04 Dec 2012, 10:15 PM
I was able to solve the Edit functionality problem by using the OnNeedDatasource method().

However, I am having some problems to use the update functionality. Since the code on the server side is retrieving the data dynamically from the table, I want to access those textbox fields (when I clicked on the Edit functionality)  through the code. Is there any way to achieve this?
0
Shinu
Top achievements
Rank 2
answered on 05 Dec 2012, 04:36 AM
Hi,

Try the following code to access values in UpdateCommand.
C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    GridEditableItem item = (GridEditableItem)e.Item;
    TextBox txt = (TextBox)item["Uniquename"].Controls[0];//accessing boundcolumn
    TextBox txt1 = (TextBox)item.FindControl("TextBox1");//accessing templatecolumn
}

Thanks,
Shinu.
0
Mahadevan
Top achievements
Rank 1
answered on 05 Dec 2012, 05:04 PM
Thanks for the response. This piece of code indeed helped me a lot.

Another question is, how do I get the code to determine what type of object (ie. RadNumeric or RadDate)? For instance my radgrid consists of string, date and numeric fields and we cannot use this line:

TextBox txt = (TextBox)item["Uniquename"].Controls[0];

So how do I determine the correct object type for the field and retrieve the value?

Also how do I retrieve the primary key of the row that I am trying to edit?

Thanks,
Swamy
0
Shinu
Top achievements
Rank 2
answered on 06 Dec 2012, 03:52 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid2_UpdateCommand(object sender, GridCommandEventArgs e)
{
  GridEditableItem editedItem = (GridEditableItem)e.Item;
  string value = editedItem.GetDataKeyValue("ID").ToString();
  RadDatePicker pkr = (RadDatePicker)editedItem.FindControl("RadDatePicker1");
}

Thanks,
Shinu.
0
Mahadevan
Top achievements
Rank 1
answered on 11 Dec 2012, 04:51 PM
Thanks for the response.

I have the radgrid grid which is displaying 15 fields. If I click on the edit, all the fields will be displayed for editing. Of these 15 fields, i want to hide 3 fields in edit mode. If it is not possible to hide the fields, would it be possible to make the fields read-only?

How do I do this?

Appreciate your help.

Thanks,
Swamy
0
Mahadevan
Top achievements
Rank 1
answered on 11 Dec 2012, 05:10 PM
Never mind....I already found the answer. Thanks anyway.
Tags
Grid
Asked by
Mahadevan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mahadevan
Top achievements
Rank 1
Share this question
or