Here is my code :
protected void CallCardStatus_RowDataBound(object sender, GridViewRowEventArgs e)
{
var thisRow = e.Row;
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (thisRow.Cells[11].Text)
{
case "MBMK":
thisRow.Cells[9].Text = "JBPM MELAKA";
break;
case "IPBJMA":
thisRow.Cells[9].Text = "JBPM KUALA LUMPUR";
break;
case "JBPMBJ":
thisRow.Cells[9].Text = "JBPM SELANGOR";
break;
default:
break;
}
}
}
here is the a part of markup for my gridview.
<asp:GridView ID="CallCardStatus" runat="server" AutoGenerateColumns="False"
OnRowDataBound="CallCardStatus_RowDataBound" HorizontalAlign="Center"
OnRowCommand="CallCardStatus_RowCommand"
DataKeyNames="call_card_no" Width="100%"
<Columns>
<asp:BoundField DataField="call_city_desc" HeaderText="City"
meta:resourcekey="BoundFieldResource4">
<HeaderStyle BackColor="#666666" BorderColor="#999999" BorderStyle="Groove"
BorderWidth="4px" Font-Names="Arial Narrow" Font-Size="Large"
HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Left" Font-Names="Arial Narrow" BorderColor="#999999"
BorderStyle="Inset" BorderWidth="2px" Font-Size="10pt" />
</asp:BoundField>
<asp:BoundField DataField="owner_department_code" HeaderText="PSCC"
Visible="False" />
</Columns>
</asp:GridView>
I want to change value in the gridview. I had tried the code above but it’s not working. Kindly please help..Siti..:)
write your logic in code behind method and call that method as follows:
if you are using template filed then call method as follows:
Or if you are using boundField Then
and your code behind method will be: