This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi I am assigning the same ID to the check box which I am searching for using FindControl() method. I'...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#21
| |||
| |||
| Hi I am assigning the same ID to the check box which I am searching for using FindControl() method. I'm doing everything the same as mentioned here: WEBSWAPP Development Inc. except for creating the columns for the GridView in the Page_Load method. The columns for the GridView are being created just before data is bound to the GridView in a number of different places in the .aspx page
__________________ G.A.P |
|
#22
| |||
| |||
| Hi You could trace out the ID of every control in gvr: foreach (Control ctrlChild in gvr.Controls) { Trace.Write("Child Item", ctrlControl.ID); } and see what .net thinks is there? |
|
#23
| |||
| |||
| Hi guys, It seems the server is not aware of the control being there at all. I tried a different approach by adding a new cell with a check box control for each row in the RowCreated event, and it works beautifully. Thanks guys.
__________________ G.A.P |
|
#24
| |||
| |||
| hey guys, I have implemented Repeater control in my web page. Working fine and information is displayed. The 30datas are displayed in this page. We dont have a paging properties in repeater control. Can anyone help me how to implement a paging to Repeater control?
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... Last edited by oxygen : 08-03-2007 at 10:59 PM. |
|
#25
| |||
| |||
| hi Oxy.... Try to implement it. I have given you the gest The PagedDataSource class encapsulates the properties of the Repeater control that allow it to perform paging. PagedDataSource pagedDataSource = new PagedDataSource(); DataView userGroupMemberDataView = new DataView(); userGroupMemberDataView = loadMyGroup(); pagedDataSource.DataSource = userGroupMemberDataView; pagedDataSource.AllowPaging = true; pagedDataSource.PageSize = 24; Last edited by Venkat : 08-04-2007 at 01:24 AM. |
|
#26
| |||
| |||
| hi, Try this code Oxygen, its worked for me..., The PagedDataSource class encapsulates the properties of the DataGrid control that allow it to perform paging. But we can use the class with Repeater and DataList controls to perform paging in much the same way as a DataGrid. Body of the page <table width="100%" border="0"> <tr > <td> <asp:label ID="lblCurrentPage" runat="server"> </asp:label></td> </tr> <tr > <td> <asp:HyperLink id="lnkPrev" runat="server"><< Prev</asp:HyperLink> <asp:HyperLink id="lnkNext" runat="server">Next >></asp:HyperLink></td> </tr> </table><asp:repeater ID="Repeater1" runat="server"> <itemtemplate> <table width="100%" border="0"> <tr > <td> <%# DataBinder.Eval(Container.DataItem, "Product") %> </td> </tr> <tr > <td> </td> </tr> </table> </itemtemplate> </asp:repeater> <script language="C#" runat="server"> public void Page_Load(Object src,EventArgs e) { DataSet ds; //Instanciate Dataset PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 5; int CurPage; if (Request.QueryString["Page"] != null) CurPage=Convert.ToInt32(Request.QueryString["Page"]); else CurPage=1; objPds.CurrentPageIndex = CurPage-1; lblCurrentPage.Text = "Page: " + CurPage.ToString(); if (!objPds.IsFirstPage) lnkPrev.NavigateUrl=Request.CurrentExecutionFilePa th + "?Page=" + Convert.ToString(CurPage-1); if (!objPds.IsLastPage) lnkNext.NavigateUrl=Request.CurrentExecutionFilePa th + "?Page=" + Convert.ToString(CurPage+1); Repeater1.DataSource=objPds; Repeater1.DataBind(); } < /script>
__________________ H2O Without us, no one can survive.. |
|
#27
| |||
| |||
| I have a GridView, I want the user to download an attachment . If there is an attachment related to that specific record. I have to download it. Can anyone help me...
__________________ H2O Without us, no one can survive.. |
|
#28
| |||
| |||
| Given below is some of my code: Private Sub projectGridView_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) ' Use the RowType property to determine whether the ' row being created is the header row. If (e.Row.RowType = DataControlRowType.Header) Then For i As Integer = 0 To e.Row.Cells.Count - 1 ' Create the sorting image based on the sort direction. Dim sortImage As Image = New Image 'Test whether or not session is exist If Session(projectGridView.Columns(i).SortExpression) Is Nothing Or Session(projectGridView.Columns(i).SortExpression) = "ASC" Then sortImage.ImageUrl = "../images/arrow_up.gif" sortImage.AlternateText = "Ascending Order" Else sortImage.ImageUrl = "../images/arrow_down.gif" sortImage.AlternateText = "Descending Order" End If ' Add the image to the appropriate header cell. e.Row.Cells(i).Controls.Add(New LiteralControl(" ")) e.Row.Cells(i).Controls.Add(sortImage) Next End If If (e.Row.RowType = DataControlRowType.DataRow) Then Dim attachmentImage As Image = New Image attachmentImage.ImageUrl = "../images/paperclip.gif" attachmentImage.AlternateText = "Attachment" 'Dim fileName As String If projectGridView.Columns(0).HeaderText = "ID" Then Dim connString As String Dim con As SqlConnection Try connString = System.Web.Configuration.WebConfigurationManager.C onnectionStrings("ConnectionString1").ConnectionSt ring con = New SqlConnection(connString) Dim cmd As SqlCommand = New SqlCommand() cmd.Connection = con cmd.CommandText = "dbo.GetOpenProjectInfo" cmd.CommandType = CommandType.StoredProcedure Dim adapter As New SqlDataAdapter(cmd) Dim proj As New DataSet adapter.Fill(proj, "Projects") 'Response.Write(proj.Tables(0).Rows.Count & " ") 'Response.Write(proj.Tables(0).Columns.Count & " ") If Not [String].IsNullOrEmpty(e.Row.Cells(0).ToString) Then Dim i Dim fileURL As String Dim dr As DataRow dr = proj.Tables(0).Rows(e.Row.RowIndex) If [String].IsNullOrEmpty(dr.Item("FileName").ToString) = False Then fileURL = Server.MapPath(".") & "\upload\" & dr("FileName").ToString 'Response.Write(" " & dr("FileName").ToString & " ") e.Row.Cells(0).Controls.Add(New LiteralControl("<a href=""" & fileURL & """>")) e.Row.Cells(0).Controls.Add(attachmentImage) e.Row.Cells(0).Controls.Add(New LiteralControl("</a>")) End If End If 'For i = 0 To ((proj.Tables(0).Rows.Count) - 1) ' Response.Write("<br />" & i & "<br />") ' Response.Write(dr.Item("FileName").ToString) 'Next i 'For Each dr As DataRow In proj.Tables(0).Rows ' If [String].IsNullOrEmpty(dr("FileName").ToString) = False Then ' Response.Write(dr("FileName").ToString & " ") ' e.Row.Cells(0).Controls.Add(New LiteralControl("")) ' e.Row.Cells(0).Controls.Add(attachmentImage) ' End If 'Next dr Try con.Open() cmd.ExecuteNonQuery() Catch ex As Exception Response.Write(ex) Finally con.Close() con.Dispose() End Try Catch ex As ApplicationException Response.Write("Could not load the database") End Try End If End If End Sub Currently the items on RowIndex 1 and 2 have attachments. When the page loads, the attachments image shows up next the "ID" column in those rows. |
|
#29
| |||
| |||
| hey, The problem now is with the paging and sorting events. If I change the page or if I sort the Grid View, the attachment image stays on rows 2 and 3 and doesn't move with it's related "ID" row. help out!
__________________ H2O Without us, no one can survive.. |
|
#30
| |||
| |||
| Hi: When we want to pop up download box, we have to do something like this: protected void Page_Load(object sender, EventArgs e) { Response.AppendHeader("content-disposition", "attachment; filename=" + "1.bmp"); Response.ContentType = "Application/pdf"; //Get the physical path to the file. string FilePath = MapPath("images/1.bmp"); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); Response.End(); } Only thing is to pass query string to that page. You can sill use <a> then. If your problem isn't solved, please inform me. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| silverlight controls for .net | stevejhon | ASP and ASP.NET Programming | 1 | 03-25-2009 10:31 AM |
| silverlight controls for .net | stevejhon | ASP and ASP.NET Programming | 0 | 03-23-2009 01:55 AM |
| How can we Dynamically create web controls | Kirubhananth | ASP and ASP.NET Programming | 3 | 03-14-2008 09:00 PM |
| WebParts controls | S.Vinothkumar | ASP and ASP.NET Programming | 5 | 11-16-2007 02:06 AM |
| Asp.net controls not supported by Ajax? | Gopisoft | ASP and ASP.NET Programming | 0 | 07-16-2007 11:22 PM |
Our Partners |