Hello telerik-Team,
i am using a GridButtonColumn with an ImageButton as follows.
<telerik:GridButtonColumn CommandName="MyCommand" ButtonType="ImageButton" UniqueName="ButtonColumn"></telerik:GridButtonColumn>
In Radgrid_ItemDataBound i am setting the ImageUrl of this Button like this:
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
if (enableBtn)
{
(dataItem["ButtonColumn"].Controls[0] as ImageButton).ImageUrl = "icon_ok.gif";
}
else
{
(dataItem["ButtonColumn"].Controls[0] as ImageButton).ImageUrl = "icon_not_ok.gif";
}
}
I want to change the image of the button depending on a value in my database/one of the gridcells.
I am using RadGrid_ItemCreated for loading the grid
if (e.Item is GridEditableItem)
{
System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.DataItem;
String enabled = rowView.Row["M_ENABLE"].ToString();
if (enabled == "0")
{
enableBtn = false;
}
if (enabled == "1")
{
enableBtn = true;
}
}
This is where i get into trouble. I now want to click on the button and change the image aswell as the value of "M_ENABLE" in the Database. But after clicking the button rowView is null. I think i need to replace the line System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.DataItem;
I just can't find out with what :D
i am using a GridButtonColumn with an ImageButton as follows.
<telerik:GridButtonColumn CommandName="MyCommand" ButtonType="ImageButton" UniqueName="ButtonColumn"></telerik:GridButtonColumn>
In Radgrid_ItemDataBound i am setting the ImageUrl of this Button like this:
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
if (enableBtn)
{
(dataItem["ButtonColumn"].Controls[0] as ImageButton).ImageUrl = "icon_ok.gif";
}
else
{
(dataItem["ButtonColumn"].Controls[0] as ImageButton).ImageUrl = "icon_not_ok.gif";
}
}
I want to change the image of the button depending on a value in my database/one of the gridcells.
I am using RadGrid_ItemCreated for loading the grid
if (e.Item is GridEditableItem)
{
System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.DataItem;
String enabled = rowView.Row["M_ENABLE"].ToString();
if (enabled == "0")
{
enableBtn = false;
}
if (enabled == "1")
{
enableBtn = true;
}
}
This is where i get into trouble. I now want to click on the button and change the image aswell as the value of "M_ENABLE" in the Database. But after clicking the button rowView is null. I think i need to replace the line System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.DataItem;
I just can't find out with what :D