|
Hi Guys
I'm afraid I'm fairly new to ASP.NET, so I'm struggling a bit with this.
I have a datalist which is getting driven by a datasource. All this works well, but I have a text field which I want to manipulate at runtime.
I currently have '<%# Eval("Body") %>' which is to display the field, but I want to replace all the New Line characters with 's so that it displays properly.
Can this be done?
Thank you in advance oooo, the Jedi's will feel this one....
|
|
|
|
|
What do you mean with...
replace all the New Line characters with 's
Be more especific!! Write at least an example or something
|
|
|
|
|
Sorry... I should have previewed that...
I meant "replace all the new line characters with the HTML line break < b r / >'s"
thanks... oooo, the Jedi's will feel this one....
|
|
|
|
|
I sorted it by performing the action in my SQL Stored Proc rather than trying to do it in the page...
Thanks anyway dudes... oooo, the Jedi's will feel this one....
|
|
|
|
|
I have 2 GridViews, the InnerGridView is nested inside a TemplateField of my OuterGridView.
Each GridView has an ObjectDataSource (ODS). I want the InnerGridView to display data that is unique
to the GroupName that is listed in the OuterGridView. I have been Googling this for weeks,
seeing various ideas based around RowDataBound and the ODS Selecting event.
I don't think RowDataBound is the answer, because the Selecting event for the InnerGridView ODS
has already been called when RowDataBound is called for the OuterGridView.
So, I need to send a parameter to the ODS for the InnerGridView:
protected void ProductDataSource_Selecting( object sender, ObjectDataSourceSelectingEventArgs e ) {
e.InputParameters["productGroup"] = <here I need to access the GroupName from the OuterGridView>;
}
Note: This method is assigned to the Selecting event of the InnerGridView ODS.
My question is: How do I access the GroupName from the OuterGridView... while I am processing the InnerGridView.
Here is an example of something that does not work: OuterGridView.SelectedRow.FindControl( "GroupName" ).ToString();
I have heard that one can find *any* control from inside the Selecting event by searching a certain hierarchy.
But I don't know how to access that hierarchy using the "e" or "sender" parms.
If I could find an explanation of the various objects and controls... and where they have a valid scope
and how they are accessed... that would be helpful.
Many thanks, Paul
|
|
|
|
|
string text1 = "";
string text2 = "";
private void insertfiles()
{
foreach (RepeaterItem item in Rptdescription.Items)
{
TextBox txt1 = (TextBox)item.FindControl("TextBox1");
TextBox txt2 = (TextBox)item.FindControl("TextBox3");
text1 += txt1.Text + "|";
text2 += txt2.Text + "|";
}
foreach (string split2 in text2.Split('|'))
{
stringList.Add(split2 + "<br/>");
SqlConnection SqlCnn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.Connection = SqlCnn;
SqlCnn.Open();
SqlCmd.CommandText = "insert into test(test,id) values(@test,1)";
SqlParameter DataBaseID = new SqlParameter("@test", SqlDbType.NVarChar, 50);
DataBaseID.Value = stringList.Add(split2);
SqlCmd.Parameters.Add(DataBaseID);
SqlCmd.ExecuteNonQuery();
SqlCnn.Close();
Bindrepeater();
}
This is how im inserting values in textbox into db..
but im having two textboxes how i need to insert both values at a time.. into db...
thank you..
|
|
|
|
|
What do you mean "insert both values at a time"? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am going to assume that you have the same number of each of the two text boxes.
First you should change your loop.
string[] box1values = text1.split('|')
string[] box3values = text1.split('|')
for (int i = 0; i < box1values.length; i++)
{
}
Then you can use the index to get the values of both strings.
SqlCmd.CommandText = "insert into test(test,test2,id) values(@test,@test2,1)";
SqlParameter test1Param= new SqlParameter("@test", SqlDbType.NVarChar, 50);
test1Param.Value = box1values[i];
SqlParameter test2Param = new SqlParameter("@test2", SqlDbType.NVarChar, 50);
test2param.Value = box3values[i];
SqlCmd.Parameters.Add(test1Param);
SqlCmd.Parameters.Add(test2param);
I wouldn't call the test1 param DataBaseID since it isn't the column named ID.
|
|
|
|
|
Hey guys,
I have a webcontrol containing a WebResource (javascript). Now the control has a few custom properties. Depending on these properties I would like to change values in the javascript. For example, the javascript by default calls a function called show(). But when the user changes a property, I would like javascript to call the fadeIn() function. Is this possible?
Cheers!
|
|
|
|
|
Dear All,
I am adding an ascx file into a content page and always I receive an unknown element error. Somehow In content page eventhough I register the ascx file, the control seems to be not known or recognized. Why do you think it happens? Here is my html code - do I miss something?
<%@ Page Language="C#" MasterPageFile="~/MAIN.Master" AutoEventWireup="true" CodeBehind="Urunler.aspx.cs" Inherits="cicektablo.Urunler" Title="flowerbox® Türkiye" %>
<%@ Register src="WebMessageBox.ascx" tagname="WebMessageBox" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">
<uc1:WebMessageBox ID="WebMessageBox1" runat="server" />
</asp:Content>
ps: I also checked the msdn and it is explianed in excatly my way. I do not understand.
|
|
|
|
|
If you need help with a specific error you should always give the exact text of the error message.
Is the user control in the same folder as the page? Did you try adding the user control by dragging and dropping into the design of the page or did you add it manually through in the aspx?
|
|
|
|
|
Thanks a lot for the answer it says webmessagebox(web user control) is not a known element... yes I tried dragging and dropping it... even so it gives the same error.
|
|
|
|
|
Here are a few things to try in whatever order you choose:
Make sure your control is in the same namespace as your pages or specify namespace in references.
Under the Build menu, Clean Solution, then rebuild.
Remove the control from the project completely, build, add it back and build again.
Create a new project file and add the pages and controls into it.
|
|
|
|
|
Hi guys.. I am working on a web application on Vb platform. Now in my application i have a button on clicking it generates an html table based on the records retrieved from my database.. Now the issue is I wanna rowspan certain cells in my html table for repeated Records... Now heres the code:
Private Sub BtnApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnApp.Click
Response.Redirect("form_frameset.aspx?sno=&page=UserApplication&keyid=&keyinfo=All")
End Sub
on the above button click it navigates to another page where the Html table gets populated.. the code on the next page is as follows:
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 page As String = Request.QueryString("page")
Dim keyid As String = Request.QueryString("keyid")
Dim keyinfo As String = Request.QueryString("keyinfo")
MyConn = New OdbcConnection(Session("sybase_constr"))
Dim SelectCmd As OdbcCommand
If page = "UserApplication" Then
Dim sqlstring As String
If keyinfo = "All" Then
sqlstring = "Select ug.UserID,u.firstname, fg.GroupID, g.GroupDesc, f.FunctionID,f.FunctionDesc from EACS_Function f, EACS_UserGroup ug, EACS_FunctionGroup fg, EACS_Group g, EACS_user_1 u where f.ApplicationID='" & keyid & "' and fg.FunctionID = f.FunctionID and fg.GroupID = ug.GroupID and ug.userid = u.userid and fg.GroupID = g.GroupID order by ug.UserID"
End If
SelectCmd = New OdbcCommand(sqlstring, MyConn)
Dim DS As DataSet
Dim MyCommand As OdbcDataAdapter
MyCommand = New OdbcDataAdapter(SelectCmd)
MyConn.Open()
DS = New DataSet
MyCommand.Fill(DS)
Dim i As Integer
i = 0
If page = "UserApplication" Then
If DS.Tables(0).Rows.Count > 0 Then
InsertPageBreak()
InsertAppUserHeader()
For i = 0 To DS.Tables(0).Rows.Count - 1
PopulateAppUsrRow(DS.Tables(0).Rows(i)(0), DS.Tables(0).Rows(i)(1), DS.Tables(0).Rows(i)(2), DS.Tables(0).Rows(i)(3), DS.Tables(0).Rows(i)(4), DS.Tables(0).Rows(i)(5))
Next
Else
Response.Write("<script language=javascript > alert('Sorry no records found'); </script>")
End If
Private Sub PopulateAppUsrRow(ByVal Usrid As String, ByVal Usrname As String, ByVal Grpid As String, ByVal Grpdsc As String, ByVal Fncid As String, ByVal FncDsc As String)
Response.Write("<tr><td align=left>" + Usrid + "</td><td align=left >" + Usrname + "</td><td align=left >" + Grpid + "</td><td align=left >" + Grpdsc + "</td><td align=left >" + Fncid + "</td><td align=left >" + FncDsc + "</td></tr>")
End Sub
Private Sub InsertPageBreak()
Response.Write("</table></font><br style='PAGE-BREAK-BEFORE:always'>")
End Sub
Private Sub InsertAppUserHeader()
Response.Write("<font face=Arial ><table cellspacing=0 width=95% border=1 ><tr><td colspan=10 align=center ><b>Abu Dhabi Islamic Bank. <br> Application Management System. </b></td></tr>")
Response.Write("<tr><th align=center>User Id</th><th align=center >User Name</th><th align=center >Group Id</th><th align=center >Group Description</th><th align=center >Function Id</th><th align=center >Function Description</th></tr>")
End Sub
Now the table which gets populated is as follows:
National Bank.
Application Management System.
User Id User Name Group Id Group Description Function Id Function Description
000120 Hassan Sid AMS01 Complete AMS A004 User
000120 Hassan Sid AMS01 Complete AMS A002 Group
000120 Hassan Sid AMS01 Complete AMS A012 Reports
000120 Hassan Sid AMS01 Complete AMS A003 Functions
000120 Hassan Sid AMS01 Complete AMS A007 Group/User
000120 Hassan Sid AMS01 Complete AMS A001 Application
000120 Hassan Sid AMS01 Complete AMS A011 Audit Trial
000120 Hassan Sid AMS01 Complete AMS A005 Group/Function
000120 Hassan Sid AMS01 Complete AMS A009 Synchronise Users
000120 Hassan Sid AMS01 Complete AMS A006 Special Group/user
000120 Hassan Sid AMS01 Complete AMS A010 Pending for Approval
001155 Ehab AMS01 Complete AMS A004 User
001155 Ehab AMS01 Complete AMS A002 Group
001155 Ehab AMS01 Complete AMS A012 Reports
001155 Ehab AMS01 Complete AMS A003 Functions
001155 Ehab AMS01 Complete AMS A007 Group/User
001155 Ehab AMS01 Complete AMS A001 Application
001155 Ehab AMS01 Complete AMS A011 Audit Trial
001155 Ehab AMS01 Complete AMS A005 Group/Function
001155 Ehab AMS01 Complete AMS A009 Synchronise Users
001155 Ehab AMS01 Complete AMS A006 Special Group/user
Now i want to row span the cells that have the same records... can any1 plzz advice me...
Thanx in advance...
Tash...
|
|
|
|
|
As you are creating the HTML already at server side.You have full control over the HTML what you have to show.Have some check at the time of creating table according to the data coming from DB. Set the rowspan.Check after the table is created,whether it is right or not.If not it means there is some problem in the creating the table. Cheers!!
Brij
|
|
|
|
|
I cant set my row span because it depends on the data retrieved from the database... Im not able to logically implement this requirement... Plz advice..
Thanx in advance,
Tash
|
|
|
|
|
<<tash18>> wrote: I cant set my row span because it depends on the data retrieved from the database...
Why, you just get the data from db, check how many records are there and where and howmauch rowsapn you need , you can decide if you are having data.Set it accordingly.You'll have to take decision of the count of rowspan after getting the data from DB. You can not hard code the rowspan.Cheers!!
Brij
|
|
|
|
|
The requirement is simply using 'control break logic'. Search for it.
Note that the sort order of the recordset is important.
Read the first record. Save the 'control break' (userid?, can be more than 1 value).
Write_All_Cells.
For every record after that...
Read.
If value same as saved 'control break' then
Write_Some_Cells (one td has a column span = n)
else
replace control break value
Write_All_Cells
|
|
|
|
|
Any sample code or articles plzz????
Thanx & regards,
Tash
|
|
|
|
|
|
Sorry im not able to cope with the replies posted here... I mean im not able to implement the logic... Im totally hit with it...
Any advice is appreciated...
Thanx in advance,
Tash
|
|
|
|
|
Yes, that whole logic thing will get you everytime.
Dim connection As New SqlConnection("server=MyServer;Trusted_Connection=true;database=MyDatabase")
connection.Open()
Dim command As New SqlCommand("select MyKey,MyField1,MyField2 from MyTable order by MyKey;", connection)
Dim reader As SqlDataReader = command.ExecuteReader()
Response.Write("<table border='1'>")
'Read the first record
reader.Read()
'Set the control break
Dim ControlBreak As Integer = CInt(reader(0))
'Write all cells
Response.Write("<tr><td>" & reader(0) & "</td><td>" & reader(1) & "</td><td>" & reader(2) & "</td></tr>")
While reader.Read()
If reader(0).Equals(ControlBreak) Then
'Write some cells
Response.Write("<tr><td colspan='2'> </td><td>" & reader(2) & "</td></tr>")
Else
'Reset the control break
ControlBreak = CInt(reader(0))
'Write all cells
Response.Write("<tr><td>" & reader(0) & "</td><td>" & reader(1) & "</td><td>" & reader(2) & "</td></tr>")
End If
End While
Response.Write("</table>")
reader.Close()
connection.Close()
|
|
|
|
|
Thanx for ur reply... but in my code i dont use reader i store it in a dataset.... so working on it.. Any advice is appreciated..
Thanx in advence..
Tash
|
|
|
|
|
Thanx a lot i found another solution for my issue.... actually i used the following code to solve it...
i used String collection to store the value and checked it and printed the table accordingly
ElseIf page = "UserApplication" Then
If DS.Tables(0).Rows.Count > 0 Then
InsertPageBreak()
InsertAppUserHeader()
Dim nfile As StringCollection = New StringCollection
Session("sc1") = nfile
For i = 0 To DS.Tables(0).Rows.Count - 1
PopulateAppUsrRow(DS.Tables(0).Rows(i)(0), DS.Tables(0).Rows(i)(1), DS.Tables(0).Rows(i)(2), DS.Tables(0).Rows(i)(3), DS.Tables(0).Rows(i)(4))
'DataSetToExcel.Convert(DS, Response)
Next
Now the Html table gets populated by the following code:
Public Sub PopulateAppUsrRow(ByVal Usrid As String, ByVal Usrname As String, ByVal Grpid As String, ByVal Grpdsc As String, ByVal FncDsc As String)
If Not Session("sc1").Contains(Usrid) Then
Session("sc1").Add(Usrid)
Response.Write("<tr><td align=left>" + Usrid + "</td><td align=left >" + Usrname + "</td><td align=left >" + Grpid + "</td><td align=left >" + Grpdsc + "</td><td align=left >" + FncDsc + "</td></tr>")
Else
Response.Write("<tr><td align=left> </td><td align=left >" + Usrname + "</td><td align=left >" + Grpid + "</td><td align=left >" + Grpdsc + "</td><td align=left >" + FncDsc + "</td></tr>")
End If
End Sub
Im happy with this kinda output.. any advice is appreciated...
Thanx in advance...
Tash
|
|
|
|
|
hi, iam using asp.net2.0 with c# with sql server
the table fields are as follows
username nvarchar
password nvarchar
emailid nvarchar
usertype int(1=administrator,2=programmer,3=manager,4=user)
active bit
so based on the user types how to give access on each page and on controls like buttons. and for different users different permissions .can you give me example which helps me
|
|
|
|