R
Radu
Hi. I have struggled for two hours now with this:
<asp:GridView
ID="GridView1"
DataSourceID="SqlDataSource1"
DataKeyNames="ID"
AutoGenerateColumns="False"
ShowFooter="True"
OnRowUpdating="GridView1_RowUpdating"
OnRowEditing="GridView1_RowEditing"
OnRowDataBound="GridView1_RowDataBound"
Runat="server"<asp:TemplateField
HeaderText="Action Type">
<ItemTemplate>
<asp:Label ID="ActionTakenLabel" Runat="Server" ><%#
Eval("ActionTaken")%></asp:Label>
</ItemTemplate>
<FooterTemplate>
<aspropDownList
ID="ActionTakenComboBoxAdd"
AutoPostBack="false"
DataSourceID="SqlDataSource2"
DataTextField="ActionTaken"
DataValueField="ActionTaken"
Runat="server">
</aspropDownList>
</FooterTemplate>
<EditItemTemplate>
<aspropDownList ID="ActionTakenComboBoxEdit"
AutoPostBack="false" DataSourceID="SqlDataSource2"
DataTextField="ActionTaken"
DataValueField="ActionTaken"
Runat="server" Text='<%# Eval("ActionTaken")%>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
protected void GridView1_RowEditing(object sender,
System.Web.UI.WebControls.GridViewEditEventArgs e)
{
String ActionType = ((DropDownList)
(GridView1.Rows[e.NewEditIndex].FindControl("ActionTakenComboBoxEdit"))).SelectedValue;
if (ActionType.IndexOf("Manually") >= 0)
{
// Cancel the edit operation.
e.Cancel = true;
String strMessage;
strMessage = "You cannot edit this record.";
Response.Write("<script language='javascript'>alert('" + strMessage
+ "');</script>");
}
}
<asp:GridView
ID="GridView1"
DataSourceID="SqlDataSource1"
DataKeyNames="ID"
AutoGenerateColumns="False"
ShowFooter="True"
OnRowUpdating="GridView1_RowUpdating"
OnRowEditing="GridView1_RowEditing"
OnRowDataBound="GridView1_RowDataBound"
Runat="server"<asp:TemplateField
HeaderText="Action Type">
<ItemTemplate>
<asp:Label ID="ActionTakenLabel" Runat="Server" ><%#
Eval("ActionTaken")%></asp:Label>
</ItemTemplate>
<FooterTemplate>
<aspropDownList
ID="ActionTakenComboBoxAdd"
AutoPostBack="false"
DataSourceID="SqlDataSource2"
DataTextField="ActionTaken"
DataValueField="ActionTaken"
Runat="server">
</aspropDownList>
</FooterTemplate>
<EditItemTemplate>
<aspropDownList ID="ActionTakenComboBoxEdit"
AutoPostBack="false" DataSourceID="SqlDataSource2"
DataTextField="ActionTaken"
DataValueField="ActionTaken"
Runat="server" Text='<%# Eval("ActionTaken")%>'>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
protected void GridView1_RowEditing(object sender,
System.Web.UI.WebControls.GridViewEditEventArgs e)
{
String ActionType = ((DropDownList)
(GridView1.Rows[e.NewEditIndex].FindControl("ActionTakenComboBoxEdit"))).SelectedValue;
if (ActionType.IndexOf("Manually") >= 0)
{
// Cancel the edit operation.
e.Cancel = true;
String strMessage;
strMessage = "You cannot edit this record.";
Response.Write("<script language='javascript'>alert('" + strMessage
+ "');</script>");
}
}