473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Gridview - empty control data when saving?

Hi guys,
I'm using a gridview to do some inline editing. The data binds okay,
its goes into edit mode and cancel okay. I'm using my own custom
commandName, "save", and it picks this up okay. Don't want to use the
built in "update" command. Trouble is when I go to access the form
fields (textboxes etc), there isn't any data there (ie text in the
textbox), I can access them though, I guess I'm missing an event
somewhere.

I've stripped out the necessary bits of code that i've used and added
it below.

Any ideas most appreciated, driving me nuts.
Regards.

**** UI ****
..
..
..

<asp:TemplateField HeaderStyle-Width="150">
<ItemTemplate><%# Eval("EmailAddress") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEmailAddress" runat="server" Text='<%#
Eval("EmailAddress") %>' />
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField ItemStyle-Width="80" ItemStyle-
HorizontalAlign="Right">
<ItemTemplate>
<asp:LinkButton CommandName="Edit" CommandArgument='<%#
Container.DataItemIndex %>' runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Content/Images/
document_edit.png" />
</asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton CommandName="Save" CommandArgument='<%#
Container.DataItemIndex %>' runat="server">
<asp:Image ID="Image2" runat="server" ImageUrl="~/Content/Images/
document_ok.png" />
</asp:LinkButton>
&nbsp;
<asp:LinkButton CommandName="Cancel" CommandArgument='<%#
Container.DataItemIndex %>' runat="server">
<asp:Image ID="Image3" runat="server" ImageUrl="~/Content/Images/
undo.png" />
</asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>

<asp:ObjectDataSource .... SelectMethod="GetAlarms" .... />


**** code behind ****
protected void RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = int.Parse(e.CommandArgument.ToString());
GridViewRow row = gvData.Rows[index];
switch (e.CommandName.ToLower())
{
case "save":
UpdateAlarmMapping(row);
gvData.EditIndex = -1;
gvData.DataBind();
break;
}
}

private void UpdateAlarmMapping(GridViewRow row)
{
Alarm alarm = new Alarm();
alarm.Enabled = ((CheckBox)row.Cells[2].Controls[0]).Checked;
alarm.EmailAddress =
((TextBox)row.FindControl("txtEmailAddress")).Text ;
alarm.MobileNumber =
((TextBox)row.FindControl("txtMobileNumber")).Text ;
alarm.AlarmNo =
int.Parse(((Literal)row.FindControl("litAlarmNo")) .Text);

bool ok = alarm.SaveAlarmMapping();
}
Jul 30 '08 #1
2 1407
Seems JQuery is causing some kind of conflict, I have my gridview in a
modal "window" (ie, div), a bunch of stuff is injected into the DOM
when it finds the div id containing my grid - i remove the call to do
this and it works fine

Now I have a different problem...
Jul 30 '08 #2
Sorted.

Seems jquery UI dialog will tear the div containing my gridview out
from where it was in the DOM and inject it directly onto the BODY tag.
So, because it's outside of the FORM tag, the fields weren't getting
posted during postback

Was able to get around this by editing the jquery library itself and
appending the dialog to the form id "aspnetForm".
Changed .appendTo(document.body) to .appendTo('#aspnetForm')

Seems to work so far :-)
Jul 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. ...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
5
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a...
1
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data...
2
by: Sean | last post by:
I am using a GridView to display and edit rows of data. I am having problems with one of my GridViews that has a Calendar control in it. If the data coming back from the DB doesn't have a date for...
3
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview control with a template column that has a textbox and when the control is bound to the datasource the textbox is filled ok. I then change what is in the textbox in the gridview...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.