|
Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 4
|
Hi
I placed a grid in a page and I have Get button.On click of Get button, records being fetched from sql server using data table and I bind it to the Grid using data source and data bind.(Say 7 rows being fetched). Now I added 2 rows to the grid by calling client-side function "grid.addItem()". Again I clicked on the Get button, script error occurs.
Thanx and Regards, Hanil.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Can you create a test page that duplicates the error? You can create a DataTable in memory and bind the Grid to that DataTable instead of from your SQL Server in the test page. Once we have the test page we will try to run it here and see if we can see the same error.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 4
|
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EOWC._Default" %>
<%@ Register Assembly="JAGregory.Controls.DeleGrid" Namespace="JAGregory.Controls" TagPrefix="cc1" %> <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <style type="text/css"> .checkbox { vertical-align:middle; text-align:right; } .combobox { font-family:Verdana; font-size:10pt; height:13pt; background-color:LightYellow; } .editbox { border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; } .inteditbox { border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; text-align:right; } </style> <script type="text/javascript"> var g_curItemIndex = -1; var object = ""; var oldvalue = "" var newvalue = ""; var strdata = "" var columnnames = "~~~Grid1_edit_Id~Grid1_edit_FirstName~Grid1_edit_LastName~Grid1_edit_Address~Grid1_edit_City~Grid1_edit_State~Grid1_edit_Country~Grid1_edit_Age" strdata = columnnames.split("~") function on_begin_edit(cell) { g_curItemIndex = cell.getItemIndex(); var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (retvalue == undefined) retvalue = ""; oldvalue = retvalue;
if (colindex < 11) { object = document.getElementById(strdata[colindex]); object.value = retvalue; } else if (colindex == 11) { object = document.getElementById("Grid1_edit_Gender"); for (var i = 0; i < object.options.length; i++) { if (object.options[i].value == retvalue) { object.selectedIndex = i; } } } setTimeout("setfocus()", 100); } function on_end_edit(cell) { var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (colindex < 11) { var sss = document.getElementById(strdata[colindex]); retvalue = sss.value; sss.value = "" } else if (colindex == 11) { var dropDownBox = document.getElementById("Grid1_edit_Gender"); var selectedIndex = dropDownBox.selectedIndex; retvalue = dropDownBox.options[selectedIndex].value; } newvalue = retvalue; if (oldvalue == "" && newvalue != "") { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } else if (oldvalue != newvalue) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "S") { item.getCell(2).setValue("U"); } else if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } return retvalue; } function on_get_text(column, item, cellValue) { if (cellValue == "M") return "Male"; else if (cellValue == "F") return "Female"; else if (cellValue == "S") return "Select";
} function setfocus() { try { object.focus(); } catch (e) {
} } function deleteItem() { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var cell1 = Grid1.getItem(a); if (cell1 != null) { cnter = cnter + 1; var cell2 = cell1.getCell(1); retval = cell2.getValue(); if (retval == 1) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(a); item.getCell(2).setValue("D"); Grid1.deleteItem(a); cnter = cnter - 1; } } } var counter = 0 if (cnter < 5) counter = 5 - cnter;
for (a = 0; a < counter; a++) { var grid = eo_GetObject("Grid1"); var additem = grid.addItem(); additem.getCell(11).setValue("S"); } } function addNewItem() { var grid = eo_GetObject("Grid1"); var cnt = Grid1.getItemCount(); cnt = parseInt(cnt) - 1; var item = grid.getItem(cnt); if (item.getCell(2).getValue() != undefined) { var item = grid.addItem(); if (item != null) { item.getCell(11).setValue("S"); item.ensureVisible(); } } } function selectall() { var checkbox = document.getElementById("Checkbox1"); var dataval = checkbox.checked; if (dataval == true) retval = "1"; else retval = "0";
var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue(retval); } } } function On_Load() { var checkbox = document.getElementById("Checkbox1"); checkbox.checked = false; var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue("0"); } } } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div id="Multiline"> <table border="0" width="980px" style="background-color:#729BC4;background-image:url('1Bar.JPG');background-repeat:no-repeat;border-color:Black;border-style:solid;border-width:1px"> <tr> <td width="48%"> <img alt="Insert" src="insert.gif" onclick="javascript:addNewItem()" style="cursor:hand"/> <img alt="Insert" src="delete.gif" onclick="javascript:deleteItem()" style="cursor:hand"/> </td> <td> <asp:Label ID="Label2" runat="server" Text="Details" style="font-stretch:wider;font-weight:bold;color:White"></asp:Label> </td> </tr> </table> <input id="Checkbox1" type="checkbox" style="position:absolute;z-index:99;left:23pt" onclick="selectall()"/> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <eo:CallbackPanel id="CallbackPanel1" runat="server" Height="0px" Width="0px" Triggers="{ControlID:Button1;Parameter:}{ControlID:Button2;Parameter:}" > <eo:Grid runat="server" id="Grid1" BorderColor="Black" BorderWidth="0px" GridLines="Both" ScrollBars="Both" EnableViewState="true" FixedColumnCount="2" GridLineColor="199, 209, 223" Width="980px" AllowColumnReorder="false" AllowPaging ="false" ClientSideOnLoad="On_Load" Height="137px" AllowNewItem="False" FullRowMode="False" GoToBoxVisible="True" ColumnHeaderAscImage="00050104" ColumnHeaderDescImage="00050105" Font-Size="10" Font-Names="Verdana" ColumnHeaderDividerImage="00050302" EnableKeyboardNavigation="True"> <ColumnHeaderStyle CssText="text-align:center;background-image:url('00050301');padding-left:2px;padding-top:2px;font-weight:bold;color:white;"></ColumnHeaderStyle> <ItemStyles> <eo:GridItemStyleSet> <ItemHoverStyle CssText="background-color:white;" /> <AlternatingItemHoverStyle CssText="background-color:lightblue;" /> <ItemStyle CssText="background-color: white" /> <AlternatingItemStyle CssText="background-color: lightblue" /> </eo:GridItemStyleSet> </ItemStyles> <ColumnTemplates> <eo:RowNumberColumn > <CellStyle CssText="text-align:right;margin-right:2px" /> </eo:RowNumberColumn> <eo:TextBoxColumn> <TextBoxStyle CssClass="editbox" /> </eo:TextBoxColumn> <eo:CheckBoxColumn > <CheckBoxStyle CssClass="checkbox"/> </eo:CheckBoxColumn> <eo:DateTimeColumn> <DatePicker runat="server" DayCellHeight="16" OtherMonthDayVisible="True" SelectedDates="" TitleRightArrowImageUrl="DefaultSubMenuIcon" DisabledDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" DayHeaderFormat="FirstLetter" ControlSkinID="None" DayCellWidth="19"> <CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma"></CalendarStyle> <TitleArrowStyle CssText="cursor:hand"></TitleArrowStyle> <PickerStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;font-family:Courier New;font-size:8pt;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;"></PickerStyle> <SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid"></SelectedDayStyle> <TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid"></TodayStyle> <MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px"></MonthStyle> <DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid"></DayHoverStyle> <DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid"></DisabledDayStyle> <DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid"></DayHeaderStyle> <OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid"></OtherMonthDayStyle> <DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid"></DayStyle> <TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;"></TitleStyle> </DatePicker> </eo:DateTimeColumn> <eo:MaskedEditColumn> <MaskedEdit runat="server" RightToLeft="true" PromptChar="_" /> </eo:MaskedEditColumn> </ColumnTemplates> <ContentPaneStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;"></ContentPaneStyle> <Columns> <eo:RowNumberColumn HeaderText = "#" Width="20" AllowResize="false" /> <eo:CheckBoxColumn HeaderText="" Width="23" AllowResize="false" /> <eo:TextBoxColumn HeaderText = "Mode" Width="50" Visible="true" /> <eo:CustomColumn HeaderText="Id" Width="150" DataField="Id" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Id" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" TargetControlID="Id" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="FirstName" Width="150" DataField="FirstName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="FirstName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="FirstName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="LastName" Width="150" DataField="LastName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="LastName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="LastName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Address" Width="150" DataField="Address" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Address" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="Address" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="City" Width="150" DataField="City" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="City" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" TargetControlID="City" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="State" Width="150" DataField="State" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="State" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" TargetControlID="State" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Country" Width="150" DataField="Country" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Country" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" TargetControlID="Country" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Age" Width="150" DataField="Age" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Age" runat="server" CssClass="inteditbox" MaxLength="3"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" TargetControlID="Age" FilterType="Custom" ValidChars="0123456789"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Gender" Width="150" DataField="Gender" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit" ClientSideGetText="on_get_text"> <EditorTemplate> <asp:DropDownList id="Gender" runat="server" style="width:150px;" CssClass="combobox"> <asp:ListItem Value="S">Select</asp:ListItem> <asp:ListItem Value="M">Male</asp:ListItem> <asp:ListItem Value="F">Female</asp:ListItem> </asp:DropDownList> </EditorTemplate> </eo:CustomColumn> </Columns> </eo:Grid> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="975" Height="200"></asp:TextBox> </eo:CallbackPanel> </ContentTemplate> <Triggers > <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click"/> <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click"/> </Triggers> </asp:UpdatePanel> </div> <asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click"/> <asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click"/> </form> </body> </html>
Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Drawing; using System.Data; using System.Text; using EO.Web;
namespace EOWC { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Initialize(); } } public void Initialize() { DataTable dt = new DataTable("Details"); DataRow dr = null; dt.Columns.Add(new DataColumn("Mode", typeof(string))); dt.Columns.Add(new DataColumn("Id", typeof(string))); dt.Columns.Add(new DataColumn("FirstName", typeof(string))); dt.Columns.Add(new DataColumn("LastName", typeof(string))); dt.Columns.Add(new DataColumn("Address", typeof(string))); dt.Columns.Add(new DataColumn("City", typeof(string))); dt.Columns.Add(new DataColumn("State", typeof(string))); dt.Columns.Add(new DataColumn("Country", typeof(string))); dt.Columns.Add(new DataColumn("Age", typeof(string))); dt.Columns.Add(new DataColumn("Gender", typeof(string))); for (int x = 0; x < 5; x++) { dr = dt.NewRow(); dr["Gender"] = "S"; dt.Rows.Add(dr); } Grid1.Columns[10].CellStyle.CssText = "text-align:right"; Grid1.DataSource = dt; Grid1.DataBind(); } public string GetConnectionString() { return System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; } protected void Button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(GetConnectionString()); DataTable dt = new DataTable("Details"); string sql = string.Empty; try { sql = "FetchData"; conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery();
SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(dt); cmd.Connection.Close(); } catch (System.Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } /*dt.Columns.Add(new DataColumn("Mode", typeof(string))); for (int x = 0; x < dt.Rows.Count; x++) { dt.Rows[x]["Mode"] = "S"; }*/ Grid1.Columns[10].CellStyle.CssText = "text-align:right"; Grid1.DataSource = dt; Grid1.DataBind(); } protected void Button2_Click(object sender, EventArgs e) { TextBox1.Text = ""; int rowcnt = Grid1.RecordCount; string datamode = ""; for (int cnt = 0; cnt < rowcnt; cnt++) { for (int col = 1; col <= 11; col++) { if (Grid1.Items[cnt].Cells[col].Value != null) { datamode = Grid1.Items[cnt].Cells[col].Value.ToString(); TextBox1.Text = TextBox1.Text + "\t" + datamode; } else { TextBox1.Text = TextBox1.Text + "\t" + " "; } } TextBox1.Text = TextBox1.Text + "\n"; } } } }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We can not run your code because it still calls your SQL Server inside Button1_Click. Can you replace that part too?
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 4
|
1. Enter some data in the grid for 5 rows. 2. Add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 3. Again add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 4. Now click on the 'Get' Button.Script error appears.
Default.aspx *********** <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EOWC._Default" %>
<%@ Register Assembly="JAGregory.Controls.DeleGrid" Namespace="JAGregory.Controls" TagPrefix="cc1" %> <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <style type="text/css"> .checkbox { vertical-align:middle; text-align:right; } .combobox { font-family:Verdana; font-size:10pt; height:13pt; background-color:LightYellow; } .editbox { border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; } .inteditbox { border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; text-align:right; } </style> <script type="text/javascript"> var g_curItemIndex = -1; var object = ""; var oldvalue = "" var newvalue = ""; var strdata = "" var columnnames = "~~~~Grid1_edit_FirstName~Grid1_edit_LastName~Grid1_edit_Address~Grid1_edit_City~Grid1_edit_State~Grid1_edit_Country~Grid1_edit_Age" strdata = columnnames.split("~") function on_begin_edit(cell) { g_curItemIndex = cell.getItemIndex(); var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (retvalue == undefined) retvalue = ""; oldvalue = retvalue;
if (colindex < 11) { object = document.getElementById(strdata[colindex]); object.value = retvalue; } else if (colindex == 11) { object = document.getElementById("Grid1_edit_Gender"); for (var i = 0; i < object.options.length; i++) { if (object.options[i].value == retvalue) { object.selectedIndex = i; } } } setTimeout("setfocus()", 100); } function on_end_edit(cell) { var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (colindex < 11) { var sss = document.getElementById(strdata[colindex]); retvalue = sss.value; sss.value = "" } else if (colindex == 11) { var dropDownBox = document.getElementById("Grid1_edit_Gender"); var selectedIndex = dropDownBox.selectedIndex; retvalue = dropDownBox.options[selectedIndex].value; } newvalue = retvalue; if (oldvalue == "" && newvalue != "") { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } else if (oldvalue != newvalue) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "S") { item.getCell(2).setValue("U"); } else if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } return retvalue; } function on_get_text(column, item, cellValue) { if (cellValue == "M") return "Male"; else if (cellValue == "F") return "Female"; else if (cellValue == "S") return "Select";
} function setfocus() { try { object.focus(); } catch (e) {
} } function deleteItem() { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var cell1 = Grid1.getItem(a); if (cell1 != null) { cnter = cnter + 1; var cell2 = cell1.getCell(1); retval = cell2.getValue(); if (retval == 1) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(a); item.getCell(2).setValue("D"); Grid1.deleteItem(a); cnter = cnter - 1; } } } var counter = 0 if (cnter < 5) counter = 5 - cnter;
for (a = 0; a < counter; a++) { var grid = eo_GetObject("Grid1"); var additem = grid.addItem(); additem.getCell(11).setValue("S"); } } function addNewItem() { var grid = eo_GetObject("Grid1"); var cnt = Grid1.getItemCount(); cnt = parseInt(cnt) - 1; var item = grid.getItem(cnt); if (item.getCell(2).getValue() != undefined) { var item = grid.addItem(); if (item != null) { item.getCell(11).setValue("S"); item.ensureVisible(); } } } function selectall() { var checkbox = document.getElementById("Checkbox1"); var dataval = checkbox.checked; if (dataval == true) retval = "1"; else retval = "0";
var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue(retval); } } } function On_Load() { var checkbox = document.getElementById("Checkbox1"); checkbox.checked = false; var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue("0"); } } } function getItem() { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); try { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var cell1 = Grid1.getItem(a); if (cell1 != null) { cnter = cnter + 1; var cell2 = cell1.getCell(1); retval = cell2.getValue();
var grid = eo_GetObject("Grid1"); var item = grid.getItem(a); item.getCell(2).setValue("D"); Grid1.deleteItem(a); cnter = cnter - 1; } } var counter = 0 if (cnter < 5) counter = 5 - cnter;
for (a = 0; a < counter; a++) { var grid = eo_GetObject("Grid1"); var additem = grid.addItem(); additem.getCell(11).setValue("S"); } } catch (e) { } alert("in"); } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div id="Multiline"> <table border="0" width="980px" style="background-color:#729BC4;border-color:Black;border-style:solid;border-width:1px"> <tr> <td width="48%"> <img alt="Insert" src="insert.gif" onclick="javascript:addNewItem()" style="cursor:hand"/> <img alt="Insert" src="delete.gif" onclick="javascript:deleteItem()" style="cursor:hand"/> </td> <td> <asp:Label ID="Label2" runat="server" Text="Details" style="font-stretch:wider;font-weight:bold;color:White"></asp:Label> </td> </tr> </table> <input id="Checkbox1" type="checkbox" style="position:absolute;z-index:99;left:23pt" onclick="selectall()"/> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <eo:CallbackPanel id="CallbackPanel1" runat="server" Height="0px" Width="0px" Triggers="{ControlID:Button1;Parameter:}{ControlID:Button2;Parameter:}"> <eo:Grid runat="server" id="Grid1" BorderColor="Black" BorderWidth="0px" GridLines="Both" ScrollBars="Both" EnableViewState="true" FixedColumnCount="2" GridLineColor="199, 209, 223" Width="980px" AllowColumnReorder="false" AllowPaging ="false" ClientSideOnLoad="On_Load" Height="137px" AllowNewItem="False" FullRowMode="False" GoToBoxVisible="True" ColumnHeaderAscImage="00050104" ColumnHeaderDescImage="00050105" Font-Size="10" Font-Names="Verdana" ColumnHeaderDividerImage="00050302" EnableKeyboardNavigation="True"> <ColumnHeaderStyle CssText="text-align:center;background-image:url('00050301');padding-left:2px;padding-top:2px;font-weight:bold;color:white;"></ColumnHeaderStyle> <ItemStyles> <eo:GridItemStyleSet> <ItemHoverStyle CssText="background-color:white;" /> <AlternatingItemHoverStyle CssText="background-color:lightblue;" /> <ItemStyle CssText="background-color: white" /> <AlternatingItemStyle CssText="background-color: lightblue" /> </eo:GridItemStyleSet> </ItemStyles> <ColumnTemplates> <eo:RowNumberColumn > <CellStyle CssText="text-align:right;margin-right:2px" /> </eo:RowNumberColumn> <eo:TextBoxColumn> <TextBoxStyle CssClass="editbox" /> </eo:TextBoxColumn> <eo:CheckBoxColumn > <CheckBoxStyle CssClass="checkbox"/> </eo:CheckBoxColumn> </ColumnTemplates> <ContentPaneStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;"></ContentPaneStyle> <Columns> <eo:RowNumberColumn HeaderText = "#" Width="20" AllowResize="false" /> <eo:CheckBoxColumn HeaderText="" Width="23" AllowResize="false" /> <eo:TextBoxColumn HeaderText = "Mode" Width="50" Visible="true" DataField="Mode"/> <eo:TextBoxColumn HeaderText = "Id" Width="150" DataField="ID" Visible="false"/> <eo:CustomColumn HeaderText="FirstName" Width="150" DataField="FirstName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="FirstName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="FirstName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="LastName" Width="150" DataField="LastName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="LastName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="LastName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Address" Width="150" DataField="Address" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Address" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="Address" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="City" Width="150" DataField="City" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="City" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" TargetControlID="City" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="State" Width="150" DataField="State" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="State" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" TargetControlID="State" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Country" Width="150" DataField="Country" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Country" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" TargetControlID="Country" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Age" Width="150" DataField="Age" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Age" runat="server" CssClass="inteditbox" MaxLength="3"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" TargetControlID="Age" FilterType="Custom" ValidChars="0123456789"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Gender" Width="150" DataField="Gender" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit" ClientSideGetText="on_get_text"> <EditorTemplate> <asp:DropDownList id="Gender" runat="server" style="width:150px;" CssClass="combobox"> <asp:ListItem Value="S">Select</asp:ListItem> <asp:ListItem Value="M">Male</asp:ListItem> <asp:ListItem Value="F">Female</asp:ListItem> </asp:DropDownList> </EditorTemplate> </eo:CustomColumn> </Columns> </eo:Grid> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="975" Height="200"></asp:TextBox> </eo:CallbackPanel> </ContentTemplate> <Triggers > <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click"/> <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click"/> </Triggers> </asp:UpdatePanel> </div> <asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click"/> <asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click"/> <input id="Button3" type="button" value="Reset" onclick="getItem()"/> </form> </body> </html>
Default.aspx.cs ************* using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Drawing; using System.Data; using System.Text; using EO.Web;
namespace EOWC { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Initialize(); } } public void Initialize() { DataTable dt = new DataTable("Details"); DataRow dr = null; dt.Columns.Add(new DataColumn("Mode", typeof(string))); dt.Columns.Add(new DataColumn("Id", typeof(string))); dt.Columns.Add(new DataColumn("FirstName", typeof(string))); dt.Columns.Add(new DataColumn("LastName", typeof(string))); dt.Columns.Add(new DataColumn("Address", typeof(string))); dt.Columns.Add(new DataColumn("City", typeof(string))); dt.Columns.Add(new DataColumn("State", typeof(string))); dt.Columns.Add(new DataColumn("Country", typeof(string))); dt.Columns.Add(new DataColumn("Age", typeof(string))); dt.Columns.Add(new DataColumn("Gender", typeof(string))); for (int x = 0; x < 5; x++) { dr = dt.NewRow(); dr["Gender"] = "S"; dt.Rows.Add(dr); } Grid1.Columns[10].CellStyle.CssText = "text-align:right"; Grid1.DataSource = dt; Grid1.DataBind(); } public string GetConnectionString() { return System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; } protected void Button1_Click(object sender, EventArgs e) { Initialize(); } protected void Button2_Click(object sender, EventArgs e) { } } }
|
|
Rank: Newbie Groups: Member
Joined: 10/27/2009 Posts: 4
|
1. Enter some data in the grid for 5 rows.(Add another 5 rows step 2to 6) 2. Add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 3. Again add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 4. Again add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 5. Again add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 6. Again add a new row by clicking on the 'Image' button on the top left of the grid and enter some data. 7. Now click on the 'Get' Button.Script error appears.
Default.aspx *********** <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EOWC._Default" %>
<%@ Register Assembly="JAGregory.Controls.DeleGrid" Namespace="JAGregory.Controls" TagPrefix="cc1" %> <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <style type="text/css"> .checkbox { vertical-align:middle; text-align:right; } .combobox { font-family:Verdana; font-size:10pt; height:13pt; background-color:LightYellow; } .editbox { border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; } .inteditbox {
border-right: #7f9db9 0px solid; border-left: #7f9db9 0px solid; border-top: #7f9db9 0px solid; border-bottom: #7f9db9 0px solid; margin-top:-1pt; font-family:Verdana; font-size:10pt; height:13pt; width:110pt; background-color:LightYellow; text-align:right; } </style> <script type="text/javascript"> var g_curItemIndex = -1; var object = ""; var oldvalue = "" var newvalue = ""; var strdata = "" var columnnames = "~~~~Grid1_edit_FirstName~Grid1_edit_LastName~Grid1_edit_Address~Grid1_edit_City~Grid1_edit_State~Grid1_edit_Country~Grid1_edit_Age" strdata = columnnames.split("~") function on_begin_edit(cell) { g_curItemIndex = cell.getItemIndex(); var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (retvalue == undefined) retvalue = ""; oldvalue = retvalue;
if (colindex < 11) { object = document.getElementById(strdata[colindex]); object.value = retvalue; } else if (colindex == 11) { object = document.getElementById("Grid1_edit_Gender"); for (var i = 0; i < object.options.length; i++) { if (object.options[i].value == retvalue) { object.selectedIndex = i; } } } setTimeout("setfocus()", 100); } function on_end_edit(cell) { var colindex = cell.getColIndex(); var retvalue = cell.getValue(); if (colindex < 11) { var sss = document.getElementById(strdata[colindex]); retvalue = sss.value; sss.value = "" } else if (colindex == 11) { var dropDownBox = document.getElementById("Grid1_edit_Gender"); var selectedIndex = dropDownBox.selectedIndex; retvalue = dropDownBox.options[selectedIndex].value; } newvalue = retvalue; if (oldvalue == "" && newvalue != "") { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } else if (oldvalue != newvalue) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(g_curItemIndex); if (item.getCell(2).getValue() == "S") { item.getCell(2).setValue("U"); } else if (item.getCell(2).getValue() == "" || item.getCell(2).getValue() == undefined) { item.getCell(2).setValue("I"); } } return retvalue; } function on_get_text(column, item, cellValue) { if (cellValue == "M") return "Male"; else if (cellValue == "F") return "Female"; else if (cellValue == "S") return "Select";
} function setfocus() { try { object.focus(); } catch (e) {
} } function deleteItem() { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var cell1 = Grid1.getItem(a); if (cell1 != null) { cnter = cnter + 1; var cell2 = cell1.getCell(1); retval = cell2.getValue(); if (retval == 1) { var grid = eo_GetObject("Grid1"); var item = grid.getItem(a); item.getCell(2).setValue("D"); Grid1.deleteItem(a); cnter = cnter - 1; } } } var counter = 0 if (cnter < 5) counter = 5 - cnter;
for (a = 0; a < counter; a++) { var grid = eo_GetObject("Grid1"); var additem = grid.addItem(); additem.getCell(11).setValue("S"); } } function addNewItem() { var grid = eo_GetObject("Grid1"); var cnt = Grid1.getItemCount(); cnt = parseInt(cnt) - 1; var item = grid.getItem(cnt); if (item.getCell(2).getValue() != undefined) { var item = grid.addItem(); if (item != null) { item.getCell(11).setValue("S"); item.ensureVisible(); } } } function selectall() { var checkbox = document.getElementById("Checkbox1"); var dataval = checkbox.checked; if (dataval == true) retval = "1"; else retval = "0";
var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue(retval); } } } function On_Load() { var checkbox = document.getElementById("Checkbox1"); checkbox.checked = false; var grid = eo_GetObject("Grid1"); var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var item = grid.getItem(a); if (item != null) { item.getCell(1).setValue("0"); } } } function getItem() { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); try { var a = 0; var retval = 0; var cnter = 0; var totalrows = Grid1.getItemCount(); for (a = 0; a < totalrows; a++) { var cell1 = Grid1.getItem(a); if (cell1 != null) { cnter = cnter + 1; var cell2 = cell1.getCell(1); retval = cell2.getValue();
var grid = eo_GetObject("Grid1"); var item = grid.getItem(a); item.getCell(2).setValue("D"); Grid1.deleteItem(a); cnter = cnter - 1; } } var counter = 0 if (cnter < 5) counter = 5 - cnter;
for (a = 0; a < counter; a++) { var grid = eo_GetObject("Grid1"); var additem = grid.addItem(); additem.getCell(11).setValue("S"); } } catch (e) { } alert("in"); } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div id="Multiline"> <table border="0" width="980px" style="background-color:#729BC4;border-color:Black;border-style:solid;border-width:1px"> <tr> <td width="48%"> <img alt="Insert" src="insert.gif" onclick="javascript:addNewItem()" style="cursor:hand"/> <img alt="Insert" src="delete.gif" onclick="javascript:deleteItem()" style="cursor:hand"/> </td> <td> <asp:Label ID="Label2" runat="server" Text="Details" style="font-stretch:wider;font-weight:bold;color:White"></asp:Label> </td> </tr> </table> <input id="Checkbox1" type="checkbox" style="position:absolute;z-index:99;left:23pt" onclick="selectall()"/> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <eo:CallbackPanel id="CallbackPanel1" runat="server" Height="0px" Width="0px" Triggers="{ControlID:Button1;Parameter:}{ControlID:Button2;Parameter:}"> <eo:Grid runat="server" id="Grid1" BorderColor="Black" BorderWidth="0px" GridLines="Both" ScrollBars="Both" EnableViewState="true" FixedColumnCount="2" GridLineColor="199, 209, 223" Width="980px" AllowColumnReorder="false" AllowPaging ="false" ClientSideOnLoad="On_Load" Height="137px" AllowNewItem="False" FullRowMode="False" GoToBoxVisible="True" ColumnHeaderAscImage="00050104" ColumnHeaderDescImage="00050105" Font-Size="10" Font-Names="Verdana" ColumnHeaderDividerImage="00050302" EnableKeyboardNavigation="True"> <ColumnHeaderStyle CssText="text-align:center;background-image:url('00050301');padding-left:2px;padding-top:2px;font-weight:bold;color:white;"></ColumnHeaderStyle> <ItemStyles> <eo:GridItemStyleSet> <ItemHoverStyle CssText="background-color:white;" /> <AlternatingItemHoverStyle CssText="background-color:lightblue;" /> <ItemStyle CssText="background-color: white" /> <AlternatingItemStyle CssText="background-color: lightblue" /> </eo:GridItemStyleSet> </ItemStyles> <ColumnTemplates> <eo:RowNumberColumn > <CellStyle CssText="text-align:right;margin-right:2px" /> </eo:RowNumberColumn> <eo:TextBoxColumn> <TextBoxStyle CssClass="editbox" /> </eo:TextBoxColumn> <eo:CheckBoxColumn > <CheckBoxStyle CssClass="checkbox"/> </eo:CheckBoxColumn> </ColumnTemplates> <ContentPaneStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;"></ContentPaneStyle> <Columns> <eo:RowNumberColumn HeaderText = "#" Width="20" AllowResize="false" /> <eo:CheckBoxColumn HeaderText="" Width="23" AllowResize="false" /> <eo:TextBoxColumn HeaderText = "Mode" Width="50" Visible="true" DataField="Mode"/> <eo:TextBoxColumn HeaderText = "Id" Width="150" DataField="ID" Visible="false"/> <eo:CustomColumn HeaderText="FirstName" Width="150" DataField="FirstName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="FirstName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="FirstName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="LastName" Width="150" DataField="LastName" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="LastName" runat="server" CssClass="editbox" MaxLength="20"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="LastName" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Address" Width="150" DataField="Address" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Address" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="Address" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="City" Width="150" DataField="City" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="City" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" TargetControlID="City" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="State" Width="150" DataField="State" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="State" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" TargetControlID="State" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Country" Width="150" DataField="Country" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Country" runat="server" CssClass="editbox" MaxLength="50"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" TargetControlID="Country" FilterType="Custom" ValidChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Age" Width="150" DataField="Age" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit"> <EditorTemplate> <asp:TextBox id="Age" runat="server" CssClass="inteditbox" MaxLength="3"></asp:TextBox> <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" TargetControlID="Age" FilterType="Custom" ValidChars="0123456789"/> </EditorTemplate> </eo:CustomColumn> <eo:CustomColumn HeaderText="Gender" Width="150" DataField="Gender" ClientSideBeginEdit="on_begin_edit" ClientSideEndEdit="on_end_edit" ClientSideGetText="on_get_text"> <EditorTemplate> <asp:DropDownList id="Gender" runat="server" style="width:150px;" CssClass="combobox"> <asp:ListItem Value="S">Select</asp:ListItem> <asp:ListItem Value="M">Male</asp:ListItem> <asp:ListItem Value="F">Female</asp:ListItem> </asp:DropDownList> </EditorTemplate> </eo:CustomColumn> </Columns> </eo:Grid> <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="975" Height="200"></asp:TextBox> </eo:CallbackPanel> </ContentTemplate> <Triggers > <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click"/> <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click"/> </Triggers> </asp:UpdatePanel> </div> <asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click"/> <asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click"/> <input id="Button3" type="button" value="Reset" onclick="getItem()"/> </form> </body> </html>
Default.aspx.cs ************* using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Drawing; using System.Data; using System.Text; using EO.Web;
namespace EOWC { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Initialize(); } } public void Initialize() { DataTable dt = new DataTable("Details"); DataRow dr = null; dt.Columns.Add(new DataColumn("Mode", typeof(string))); dt.Columns.Add(new DataColumn("Id", typeof(string))); dt.Columns.Add(new DataColumn("FirstName", typeof(string))); dt.Columns.Add(new DataColumn("LastName", typeof(string))); dt.Columns.Add(new DataColumn("Address", typeof(string))); dt.Columns.Add(new DataColumn("City", typeof(string))); dt.Columns.Add(new DataColumn("State", typeof(string))); dt.Columns.Add(new DataColumn("Country", typeof(string))); dt.Columns.Add(new DataColumn("Age", typeof(string))); dt.Columns.Add(new DataColumn("Gender", typeof(string))); for (int x = 0; x < 5; x++) { dr = dt.NewRow(); dr["Gender"] = "S"; dt.Rows.Add(dr); } Grid1.Columns[10].CellStyle.CssText = "text-align:right"; Grid1.DataSource = dt; Grid1.DataBind(); } public string GetConnectionString() { return System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; } protected void Button1_Click(object sender, EventArgs e) { Initialize(); } protected void Button2_Click(object sender, EventArgs e) { } } }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Try to set the Grid's SelectedItemIndex and SelectedCellIndex to -1 inside your Button1_Click and see if it helps.
Thanks!
|
|