IT Community - Software Programming, Web Development and Technical Support

ASP.NET Data Controls

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'...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #21  
Old 08-03-2007, 05:20 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Default Re: Implementation Data Controls in asp.net

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22  
Old 08-03-2007, 05:22 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Default Re: Implementation Data Controls in asp.net

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?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23  
Old 08-03-2007, 05:23 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Thumbs up Re: Implementation Data Controls in asp.net

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24  
Old 08-03-2007, 08:39 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Default Re: Implementation Data Controls in asp.net

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25  
Old 08-04-2007, 01:22 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26  
Old 08-04-2007, 01:32 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 245
H2o is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

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>&nbsp;&nbsp;<asp:label ID="lblCurrentPage" runat="server">
</asp:label></td>
</tr>
<tr >
<td>&nbsp;&nbsp;
<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>&nbsp;&nbsp; <%# DataBinder.Eval(Container.DataItem, "Product") %> </td>
</tr>
<tr >
<td>&nbsp;&nbsp; </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..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27  
Old 08-08-2007, 05:08 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 245
H2o is on a distinguished road
Question Re: Implementation Data Controls in asp.net

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..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28  
Old 08-08-2007, 05:20 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

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(" &nbsp;&nbsp;&nbsp;" & dr("FileName").ToString & " &nbsp;&nbsp;&nbsp;")
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 & " &nbsp;&nbsp;&nbsp;")
' 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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29  
Old 08-08-2007, 05:41 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 245
H2o is on a distinguished road
Question Re: Implementation Data Controls in asp.net

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..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30  
Old 08-08-2007, 05:42 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 347
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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


All times are GMT -7. The time now is 01:48 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0