Jump to content

kreplech

Members
  • Content Count

    33
  • Joined

  • Last visited

Community Reputation

0 Neutral

About kreplech

  • Rank
    Newbie
  • Birthday 11/17/1975

Profile Information

  • Location
    LA
  1. this may actually be the least complicated thing ever...you can set the caption on the gridview... duh... i'll stop wasting bandwidth now...
  2. correction... i don't think checking the ods will work. The ods uses the .xsd from the updatepanel... that probably complicates things further...
  3. hello all,i have a setup sort of like (please excuse the pseudocode):<label text="this section" /><ajax updatepanel> <gridview datasource="objectdatasource1"> ... stuff here </gridview></ajax updatepanel>i'd like the label to only show if there is data to be displayed in the gridview... but i don't see any obvious methods (i.e. if objectdatasource1.eof...)any ideas?Thanks,M
  4. kreplech

    updatepanel woes

    Using code behind was my first instinct as, i agree, i feel handcuffed without accessing the code... but my biggest obstacle so far - and you've helped me with this at least once before - is accessing variables using code behind. it seems like every control requires different syntax. for example, the datalist you helped me with used the syntax: string fileType = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "fileTyp")); to get the value of a hidden control within a datalist... but required ((Image)e.Item.FindControl("fileIcon")).ImageUrl = "images/pdf.gif"; to access the image control from the same datalist... i don't understand the difference... and neither of them worked for a gridview.can you recommend a tutorial or reference site for this type of stuff. is there a particularly good book for C#? I'm such a whiny newb...Thanks again for all the help.M
  5. kreplech

    updatepanel woes

    nicely done... thanks again! i think i owe you my car or something... anyway, it works now - and i've learned quite a bit in the process...
  6. kreplech

    updatepanel woes

    OK - so i realized a couple of things this morning that my eyes were too tired to see last night.First of all - I hadn't formed my objectdatasource correctly... no update parms... ANYWAY, so now it looks like: <asp:ObjectDataSource ID="odsPapers" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="selectPapersTableAdapters.tbl_CTS_PapersTableAdapter" UpdateMethod="Update"> <SelectParameters> <asp:SessionParameter Name="APPLID" SessionField="RANDID" Type="String" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="paperid" Type="Int32" /> <asp:Parameter Name="statusfk" Type="Boolean" /> <asp:Parameter Name="paperTitle" Type="String" /> </UpdateParameters> </asp:ObjectDataSource> Also, I've added the primary key of my table as a hidden control... maybe not necessary since the gridview has it in the datakeynames? anyway, so now it looks like: <ajax:UpdatePanel ID="upPapers" runat="server"> <ContentTemplate> <div style="width:525px;"> <asp:GridView ID="gvPapers" ShowHeader="true" runat="server" AutoGenerateColumns="False" DataKeyNames="paperid" DataSourceID="odsPapers"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:LinkButton Text="Edit" CommandName="Edit" CausesValidation="false" runat="server" ID="btEdit" /> </ItemTemplate> <EditItemTemplate> <asp:LinkButton Text="Update" CommandName="Update" CausesValidation="true" runat="server" ID="btUpdate" /> <asp:LinkButton Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" ID="btCancel" /> </EditItemTemplate> </asp:TemplateField> <asp:CheckBoxField DataField="statusfk" HeaderText="Status" SortExpression="statusfk" /> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblFileType" Text='<%# Eval("FileTyp") %>' runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="PaperTitle" SortExpression="PaperTitle"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("PaperTitle") %>' NavigateUrl='<%# "http://galileo2.rand.org/candidate/papers/" + Eval("FileURL") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtPaperTitle" runat="server" Text='<%# Bind("PaperTitle") %>' Rows="2" TextMode="MultiLine" style="width:350px; font:11px arial;" ></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblFileSize" Text='<%# Eval("FileSiz") %>' runat="server" style="white-space:nowrap" /> <asp:HiddenField ID="paperid" Value='<%# Eval("paperid") %>' runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </ContentTemplate> </ajax:UpdatePanel> finally, i found that my updatepanel did not have any command text associated with the update method... so i've filled in the proper update statement (UPDATE dbo.tbl_CTS_Papers SET statusfk = @statusfk, PaperTitle = @paperTitle WHERE (paperid = @paperid))so, now i get a different error:ObjectDataSource 'odsPapers' could not find a non-generic method 'Update' that has parameters: statusfk, PaperTitle, original_paperid.oddly, i have no reference to a var named original_paperid anywhere that i can find... nor have i ever that i can remember... very confusing.any ideas?
  7. kreplech

    updatepanel woes

    any code behind is completely ignored as the update link in the gridview produces only the "No parameterless constructor is defined for this object" error everytime it is clicked. currently all the code is commented out. is there a particular event i need to tie to the update button - or gridview?
  8. kreplech

    updatepanel woes

    hello all,i am having trouble learning how to use the ajax updatepanel. when i try to update a row, i receive the message "No parameterless constructor is defined for this object"... i am just learning, and completely clueless...Anyway, just hoping somebody can explain this to me in newbie-speak. I'm trying to get the gridview row to let the user update only the statusfk and paperTitle fields. so far, when EDIT is clicked, the proper controls are displayed, however, the aforementioned error occurs when UPDATE is clicked. Any ideas?My code follows:asp: <asp:Label ID="lblTest" runat="server" Text="Label"></asp:Label> <ajax:UpdatePanel ID="upPapers" runat="server"> <ContentTemplate> <div style="width:525px;"> <asp:GridView ID="gvPapers" ShowHeader="true" runat="server" AutoGenerateColumns="False" DataKeyNames="paperid" DataSourceID="odsPapers"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:LinkButton Text="Edit" CommandName="Edit" CausesValidation="false" runat="server" ID="btEdit" /> </ItemTemplate> <EditItemTemplate> <asp:LinkButton Text="Update" CommandName="Update" CausesValidation="true" runat="server" ID="btUpdate" /> <asp:LinkButton Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" ID="btCancel" /> </EditItemTemplate> </asp:TemplateField> <asp:CheckBoxField DataField="statusfk" HeaderText="Status" SortExpression="statusfk" /> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblFileType" Text='<%# Eval("FileTyp") %>' runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="PaperTitle" SortExpression="PaperTitle"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("PaperTitle") %>' NavigateUrl='<%# "http://galileo2.rand.org/candidate/papers/" + Eval("FileURL") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtPaperTitle" runat="server" Text='<%# Bind("PaperTitle") %>' Rows="2" TextMode="MultiLine" style="width:350px; font:11px arial;" ></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblFileSize" Text='<%# Eval("FileSiz") %>' runat="server" style="white-space:nowrap" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </ContentTemplate> </ajax:UpdatePanel> any help is truly appreciated.Thanks,M
  9. found the fix... and i'm feeling very impressed with myself.I dropped the rs.cursorlocation = 3 altogetherand changed the open recordset statement to:rs.Open "select * from thisTable;", conn, 2, 2 ' adOpenDynamic which seems kinda obvious now.Thanks!M
  10. Hello all,Below is a little script I wrote to remove URL encoding from every field in a table. I had to write it because many of the database fields are NTEXT barring me from using the SQL REPLACE function. So I'll need to use the following VBS script as a scheduled windows task on the server (URL encoded data is imported nightly)... easy enough. Well, for some reason the update isn't committing - despite the fact that the script runs without any errors. I'd like to use rs.update rather than writing an UPDATE statement since my table has no primary key (GASP!). Anyway, if you can spot the problem, please fill me in.Thanks in advance for any help,M_____________________________________________Set conn = CreateObject("ADODB.Connection")Set rs = CreateObject("ADODB.Recordset")conn.open "Driver={SQL Native Client};Server=server;Database=db;Uid=user;Pwd=pass;"rs.cursorlocation = 3rs.Open "select * from thisTable;", conn, 2, 4While Not rs.EOF For Each Field In rs.Fields If (Field.Type = 202 Or Field.Type = 203 Or Field.Type = 201) And Not (IsNull(Field.Value)) And Field.Value <> "" Then updateVal = Trim(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Field.Value, "%20", " "), "%2F", "/"), "%2C", ","), "%3A", ":"), "%25", "%"), "%5C%27", "'"), "%85", "..."), "%93", "'"), "%94", "'"), "%3F", "?"), "%E2%80%99", ""), "%5C%22", "'"), "%28", "("), "%29", ")"), "%26", "&"), "%3B", ";"), "%96", "–"), "%97", "—"), "%92", "’"), "%0d", ""), "%0a", ""), "%23", "#"), "%22", "'"), "%27", "'"), "%7E", "~"), "%24", "$"), "%95", "•"), "%09", " "), "%5C%22", "'")) If updateVal <> Field.Value Then msgbox(Field.Value) ' Correctly displays the unReplaced field rs(Field.Name).Value = updateVal rs.update msgbox(Field.Value) ' Correctly display the Replaced field, but update never happened... End If End If Next rs.MoveNextWendrs.Closeconn.Closemsgbox("Done!")
  11. Thank you! This is very helpful.
  12. Hi Jesh,Thanks for the reply... sorry it took me so long to respond.Still can't get it to work... but...I had to make a change:string fileType = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "FileType")); // instead of .ToStringalso, now it's telling me: CS0117: 'System.Web.UI.Control' does not contain a definition for 'ImageUrl'Strange... I don't have any time to play with it right now, but I'll try a few things later to see if anything works... and update ya.Thanks again,M
  13. I think I'm starting to understand that I have no idea what I'm doing... I mean that in the best possible way... Hopefully it's a notch on the learning curve...Anywho...So, I have a datasource and a datalist like so:<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CTS_Conn %>" SelectCommand="SELECT [PaperTitle], [FileTyp], [FileURL], [FileSiz] FROM [qryValidPapers] WHERE ([cid] = @cid)"> <SelectParameters> <asp:QueryStringParameter Name="cid" QueryStringField="CID" Type="String" /> </SelectParameters></asp:SqlDataSource><asp:DataList ID="DataList2" runat="server" DataSourceID="SqlDataSource3" OnLoad="DataList2_OnLoad"> <ItemTemplate> <asp:HiddenField ID="fileType" runat="server" Value='<%# Eval("FileTyp") %>' /> <asp:Image ID="fileIcon" runat="server" ImageUrl="" /> <asp:Label ID="fileTitle" runat="server" Text='<%# Eval("PaperTitle") %>'></asp:Label> <asp:Label ID="fileURL" runat="server" Text='<%# Eval("FileURL") %>'></asp:Label> <asp:Label ID="fileSize" runat="server" Text='<%# "(" + Eval("FileSiz") + ")" %>'></asp:Label> <br /> </ItemTemplate></asp:DataList>Now, what I'm trying to do is determine which icon to display in the image control fileIcon depending on the value of the label fileType... problem is, not matter what I do, I can't see any of the controls in my datalist from my method (which method you ask? any of them... i've tried them all).HOWEVER!!! I've realized that I can see any other control on the screen from the method... leading me to believe that the datalist method can't see it's own controls because they haven't been loaded, rendered, or whatever'ed yet.So... two questions:1) Am I just WAAAYYYYY off base here?2) So what to do? Not use a datalist? Hop around the dataset the same way I would've using classic asp?As usual: any help is much appreciated.Thanks again,Mand just for giggles... my OnLoad method that does little other than generate a joyful "System.NullReferenceException: Object reference not set to an instance of an object." error...protected void DataList2_OnLoad(object sender, EventArgs e) { HiddenField fileType = (HiddenField)DataList2.FindControl("fileType"); Label3.Text = ":" + fileType; // I can see Label3, but fileType is NULL... just like everything else. Image fileIcon = (Image)DataList2.FindControl("fileIcon"); if (Convert.ToString(fileType) == "PDF") // tests false because fileType is NULL { fileIcon.ImageUrl = "/images/pdf.gif"; // no error here probably because I test false for the IF conditional } else { fileIcon.ImageUrl = "/images/text.gif"; // causes the error... } }
  14. Based on responses I've received in other forums - this is dynamic sql thereby punishable by death. I'm looking into more socially acceptable means of implementing dSQL; however, in the meantime i'll bite the bullet and stick with my cumbersome sprocs.Thanks again,M
  15. OK - Maybe this is the best way:SQL:putData sproc accepts params @fieldname @fieldvalue @recordIDC# functions:openDBcloseDBputDataLogic:If I want to update field1, field2, field3 thenopenDBputData(@fieldName, @fieldValue, @recordID) // for field1putData(@fieldName, @fieldValue, @recordID) // for field2putData(@fieldName, @fieldValue, @recordID) // for field3closeDBis that stupid? it saves me from have to call putData(field1,field2,field3, .... , fieldx) and sending mostly NULL values or blanks when I only want to update one field.Also, I realize this post has drifted away from .NET progging - sorry 'bout that... but thanks for the help!
×
×
  • Create New...