Click here to Skip to main content
15,911,711 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionclose modal dialouge box Pin
yesu prakash12-Mar-07 4:46
yesu prakash12-Mar-07 4:46 
AnswerRe: close modal dialouge box Pin
SABhatti12-Mar-07 5:24
SABhatti12-Mar-07 5:24 
QuestionLogin Error Pin
reddyamar_uk12-Mar-07 4:33
reddyamar_uk12-Mar-07 4:33 
AnswerRe: Login Error Pin
badgrs12-Mar-07 5:48
badgrs12-Mar-07 5:48 
AnswerRe: Login Error [modified] Pin
RichardGrimmer12-Mar-07 6:48
RichardGrimmer12-Mar-07 6:48 
QuestionRetrieving Full URL from a relative url Pin
dabs12-Mar-07 3:20
dabs12-Mar-07 3:20 
AnswerRe: Retrieving Full URL from a relative url Pin
Walter_H12-Mar-07 4:26
Walter_H12-Mar-07 4:26 
QuestionUpdating GridView row bound to ObjectDataSource Pin
mcs13012-Mar-07 3:47
mcs13012-Mar-07 3:47 
I apologize in advance for the detail in this post...but w/o it, I don't think it will be clear. (code snippet below)

I have been trying to follow an example discussed at http://msdn2.microsoft.com/en-us/library/ms972948.aspx. I have a very similar application - attempting to update a row in a collection of objects bound to a GridView object through an ObjectDataSource. I have 2 methods on a DAL object that I have provided for the ObjectDataSource: getALMPropDataTable() and <b>updateALMProp( int almPropNbr, String almPropNm, String almPropVal)</b>. The getALMPropDataTable() works perfectly, no issues. However, when attempting the Update, a problem arises...
1) Clicking the Edit Button (1st col) of the GridView seems to work OK...and the one column that is editable appears w/ a TextBox - no problem there.
2) In this mode, the Edit Button is replaced w/ an Update and Cancel Button pair as expected - no problem there.
3) When clicking the Update Button, the updateALMProp( int almPropNbr, String almPropNm, String almPropVal) method is called (as expected), however, Trace.Warn messages that I have placed just inside this method reveal the following:

ALMPropVwDAO.updateALMProp() from DAO Layer...
<b>almPropNbr: 0 almPropNm: almPropVal: stuff</b>

Only the 3rd argument is received. No matter what row I attempt to update, I get this same behavior (the 0 value of almPropNbr is always zero regardless of row since this type is Int32 - ie: I don't get the row number as expected). The almPropNm value is empty (it should be name of the property... so that's a problem). Only the value typed into the TextBox on the row in Edit mode actually comes across. The almPropNm is actually the key needed to get the right object of the collection, so consequently no update can performed (the almPropNbr value is technically not required for the update, it is just a row marker for log tracing). If anyone has any ideas, I'd appreciate it...thanks in advance.

Here's the aspx file:


<asp:GridView ID="GridViewALMProp" runat="server" AutoGenerateColumns="False" Width="400px" BackColor="White" BorderColor="#999999"
DataSourceID="ObjectDataSource1" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical"
AllowPaging="True" AllowSorting="True" EmptyDataText="No records found" PagerSettings-Mode="NumericFirstLast" PageSize="5" >
<FooterStyle BackColor="LightGray" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="Gainsboro" ForeColor="Blue" HorizontalAlign="Center" />
<HeaderStyle BackColor="DarkBlue" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#00C000" ForeColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" ButtonType="Button" />
<asp:BoundField DataField="ALMPropNbr" ReadOnly="true" HeaderText="Number" SortExpression="ALMPropNbr" />
<asp:BoundField DataField="ALMPropNm" ReadOnly="true" HeaderText="Property Name" SortExpression="ALMPropNm" />
<asp:BoundField DataField="ALMPropVal" HeaderText="Property Value" SortExpression="ALMPropVal" />
</Columns>
<PagerSettings Mode="NumericFirstLast" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="ALMPropVwDAO" SelectMethod="getALMPropDataTable" UpdateMethod="updateALMProp">
<UpdateParameters>
<asp:Parameter Name="ALMPropNbr" Type="Int32" />
<asp:Parameter Name="ALMPropNm" Type="String" />
<asp:Parameter Name="almPropVal" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>



Here's the method called:


public static void updateALMProp( int almPropNbr, String almPropNm, String almPropVal)
{

HttpContext.Current.Trace.Warn("ALMPropVwDAO.updateALMProp() from DAO Layer...");
HttpContext.Current.Trace.Warn("almPropNbr: " + almPropNbr + " almPropNm: " + almPropNm + " almPropVal: " + almPropVal);

try
{
// get ALM object from Session
ALM alm = (ALM)HttpContext.Current.Session[RequestConstants.ALMObj];
HttpContext.Current.Trace.Warn("ALM from Session: " + alm.ToString());

ALMProp[] almProps = alm.ALMProps;

for (int i = 0; i < almProps.Length; i++)
{
HttpContext.Current.Trace.Warn("almPropNm: " + almPropNm + " | " + "almProps[i].ALMPropPK.ALMPropNm: " + almProps[i].ALMPropPK.ALMPropNm);
// find entry in ALMProp Array and update value
if (almProps[i].ALMPropPK.ALMPropNm.Equals(almPropNm))
{
HttpContext.Current.Trace.Warn ("found ALMProp[] object, i= " + i);
almProps[i].ALMPropVal = almPropVal;
}
}

alm.ALMProps = almProps; // set updated Array back on ALM object

// place ALM object back on Session

HttpContext.Current.Session[RequestConstants.ALMObj] = alm;

}
catch (Exception)
{
}

}


AnswerRe: Updating GridView row bound to ObjectDataSource Pin
mcs13012-Mar-07 16:52
mcs13012-Mar-07 16:52 
QuestionCan't Execute My content page Pin
Waheed AL Barghouthi12-Mar-07 3:46
Waheed AL Barghouthi12-Mar-07 3:46 
AnswerRe: Can't Execute My content page Pin
Imran Khan Pathan12-Mar-07 3:57
Imran Khan Pathan12-Mar-07 3:57 
GeneralRe: Can't Execute My content page Pin
Waheed AL Barghouthi12-Mar-07 6:28
Waheed AL Barghouthi12-Mar-07 6:28 
AnswerRe: Can't Execute My content page Pin
szukuro12-Mar-07 4:56
szukuro12-Mar-07 4:56 
QuestionCheckBox List Pin
w13RTH70Lo12-Mar-07 3:32
w13RTH70Lo12-Mar-07 3:32 
AnswerRe: CheckBox List Pin
SABhatti12-Mar-07 3:36
SABhatti12-Mar-07 3:36 
AnswerRe: CheckBox List Pin
Imran Khan Pathan12-Mar-07 3:41
Imran Khan Pathan12-Mar-07 3:41 
AnswerRe: CheckBox List Pin
postmaster@programmingknowledge.com12-Mar-07 4:28
postmaster@programmingknowledge.com12-Mar-07 4:28 
QuestionText Validation Pin
Wajihs12-Mar-07 3:15
Wajihs12-Mar-07 3:15 
AnswerRe: Text Validation Pin
SABhatti12-Mar-07 3:21
SABhatti12-Mar-07 3:21 
AnswerRe: Text Validation Pin
Spunky Coder12-Mar-07 3:31
Spunky Coder12-Mar-07 3:31 
QuestionAJAX Problem (paging, sorting, editing) [modified] Pin
SABhatti12-Mar-07 3:13
SABhatti12-Mar-07 3:13 
AnswerRe: AJAX Problem (paging, sorting, editing) Pin
badgrs12-Mar-07 5:45
badgrs12-Mar-07 5:45 
GeneralRe: AJAX Problem (paging, sorting, editing) Pin
SABhatti12-Mar-07 5:50
SABhatti12-Mar-07 5:50 
QuestionError in Switching Between HTTP and HTTPS Automatically Pin
swapnilbhavsar12-Mar-07 3:12
swapnilbhavsar12-Mar-07 3:12 
Questionpdf user authentication Pin
szewanng12-Mar-07 3:00
szewanng12-Mar-07 3:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.