eeccll
01-04-2006, 04:30 AM
does anyone knows how to display multiple lines of text in one row for datagrid..?
|
Click to See Complete Forum and Search --> : multiline datagrid eeccll 01-04-2006, 04:30 AM does anyone knows how to display multiple lines of text in one row for datagrid..? eeccll 01-04-2006, 05:54 AM can we change the Button Column to our own image button? instead of using the default push button.. eeccll 01-04-2006, 10:20 AM hihi.. can anyone help me in doing custom paging for datagrid?? I've found this sample codes >> http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/datagrid12.src The sample doesnt connect to database, but for me, i want it to display from database, how should i do it? eeccll 01-04-2006, 11:38 AM hihi.. why i cant go to the next page of the paging?? Here are the codes.. Can anyone help me?? Plssss.. thanks!! Public Class Admin1 Inherits System.Web.UI.Page Protected WithEvents Image1 As System.Web.UI.WebControls.Image Protected WithEvents Image2 As System.Web.UI.WebControls.Image Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid Protected WithEvents AncPost As System.Web.UI.WebControls.TextBox Protected WithEvents PostAncButton As System.Web.UI.WebControls.ImageButton Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection Protected WithEvents AnnouncementSelectCmd As System.Data.SqlClient.SqlCommand Protected WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents AnnouncementDA As System.Data.SqlClient.SqlDataAdapter Protected WithEvents AnnouncementDS As ELibrarySys.DataSet1 Protected WithEvents Welcome As System.Web.UI.WebControls.Label Dim cn As New SqlClient.SqlConnection() Dim cm As New SqlClient.SqlCommand() Dim da As New SqlClient.SqlDataAdapter() Dim ds As New DataSet() Dim alertScript As String Dim startIndex As Integer Dim endIndex As Integer Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim cn As New SqlClient.SqlConnection("data source=CHIONG;initial catalog=library;integrated security=SSPI;persist security info=False;workstation id=CHIONG;packet size=4096") If Not IsPostBack Then If Not (Session("Administrator") = "") Then Welcome.Text = (Session("Administrator")) Else Session.Abandon() Response.Redirect("Login.aspx") End If Dim SQLSelect As String = "SELECT Count(*) FROM Announcement" Dim cm As New SqlClient.SqlCommand(SQLSelect, cn) cn.Open() DataGrid1.VirtualItemCount = cm.ExecuteScalar() cn.Close() startIndex = 1 BindGrid() AnnouncementDA.Fill(AnnouncementDS) DataGrid1.DataBind() End If End Sub Sub BindGrid() endIndex = startIndex + DataGrid1.PageSize Dim cn As New SqlClient.SqlConnection("data source=CHIONG;initial catalog=library;integrated security=SSPI;persist security info=False;workstation id=CHIONG;packet size=4096") Dim SQLSelect2 As String = "SELECT AncID, AncMsg, AncDate FROM Announcement WHERE AncID > @startIdx AND AncID <= @endIdx ORDER BY AncID" Dim da As New SqlClient.SqlDataAdapter(SQLSelect2, cn) da.SelectCommand.Parameters.Add("@startIdx", startIndex) da.SelectCommand.Parameters.Add("@endIdx", endIndex) Dim ds As New DataSet() da.Fill(ds) DataGrid1.DataSource = ds DataGrid1.DataBind() If Not Page.IsPostBack Then Dim totalRecords As Integer = CInt(DataGrid1.VirtualItemCount) Dim totalPages As Decimal = Decimal.Parse(totalRecords.ToString()) / DataGrid1.PageSize End If End Sub Function sMsgbox(ByVal errors As String) alertScript = "<script language=javascript>" alertScript &= "alert('" & errors & "');" alertScript &= "</script" & ">" Response.Write(alertScript) End Function Private Sub PostAncButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles PostAncButton.Click If AncPost.Text = "" Then Call sMsgbox("Please Enter announcement") AncPost.Text = "" Else Dim myVar myVar = System.DateTime.Now Dim cn As New SqlClient.SqlConnection("data source=CHIONG;initial catalog=library;integrated security=SSPI;persist security info=False;workstation id=CHIONG;packet size=4096") Dim SQL As String = "INSERT INTO Announcement (AdminID, AncDate, AncMsg) VALUES ('" & Session.Contents("Administrator") & "', '" & myVar & "', '" & AncPost.Text & "')" Dim cm As New SqlClient.SqlCommand(SQL, cn) cn.Open() cm.ExecuteNonQuery() Response.Redirect("AdminHomePage.aspx") cn.Close() End If End Sub Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged End Sub End Class eeccll 01-04-2006, 01:59 PM Why i din get this code behind >> Sub DataGrid1_PageIndexChanged( s As Object, e AsDataGridPageChangedEventArgs ) instead what i get is this one >> Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) With this, i cant call the NewPageIndex property.. what should i do..? webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |