How to bold particular text in the result from SQL Server procedure - asp.net

I have a column in my stored procedure which contains following data, in row by row manner :
Ajay Tegar (1052), Amol Kumar Gupta (1409), Dilip Yadav (1369)
Now I want only data in brackets to be bold and else everything regular, like so:
Ajay Tegar (1052), Amol Kumar Gupta (1409), Dilip Yadav
(1369)
I am using grid view to show these data in asp.net web page.

I used below code at code side to bold particular text in gridview -
Label lbl_emp_name = (Label)e.Row.FindControl("lbl_empName_report");
if (lbl_emp_name.Text.Contains("("))
{
string [] splitedText = lbl_emp_name.Text.Split('(');
lbl_emp_name.Text = splitedText[0] + "<b>(" + splitedText[1] + "</b>";
}

Related

Show table by button click

TABLES: mara, marc.
"marc is N
"mara is 1
SELECTION-SCREEN PUSHBUTTON 15(10) text-001 USER-COMMAND press.
DATA: lt_mara TYPE TABLE OF mara WITH HEADER LINE,
ls_mara TYPE mara.
DATA: lt_marc TYPE TABLE OF marc WITH HEADER LINE,
ls_marc TYPE marc,
Sum type P length 8 DECIMALS 2.
PARAMETERS: p_mtart TYPE mara-mtart.
SELECT-OPTIONS: so_werks FOR marc-werks.
SELECT * FROM mara INTO TABLE lt_mara
WHERE mtart = p_mtart.
IF sy-subrc = 0.
SELECT * FROM marc INTO TABLE lt_marc
FOR ALL ENTRIES IN lt_mara
WHERE matnr = lt_mara-matnr
AND werks IN so_werks.
LOOP AT lt_marc INTO ls_marc.
READ TABLE lt_mara INTO ls_mara
WITH KEY matnr = ls_marc-matnr.
sum = ls_mara-brgew + ls_mara-ntgew .
WRITE:/ ls_mara-mtart, ls_marc-matnr , ls_marc-werks , ls_mara-brgew, ls_mara-ntgew,sum.
ENDLOOP.
ELSE.
MESSAGE TEXT-e02 TYPE 'E' .
ENDIF.
How Can make this happen:I want that on click of the button to show the table.Please the code to be as simple as possible and as easy to understand as possible.if you can't make it with a button make it with a radiobutton or smth else.
Thanks in advance!
If you want to keep it simple, you can use "sy-ucomm" which stores your last triggered action. With your button, it'd look like this:
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'PRESS'.
*code for displaying your table via ALV or WRITE goes here*
ENDCASE.
The most common way to display internal tables like this is with an ALV, a simple example of how to build up an ALV can be found here:
https://archive.sap.com/discussions/thread/873601
If you'd like it to do the WRITE: to screen under one circumstance, and display the ALV Grid in another, you should use Select Options and parameters.
Your code needs the addition of EVENTS, please take a look here on what they are and how to use them:
http://www.erpworkbench.com/abap/abap-events.htm

How to select frame if there are multiple frames on a webpage and get content of that frame?

I am trying to get the content of the email from site name "yopmail.com" which is having multiple frames. I need to switch to the frame name = 'ifmail' and want to getText from email body.
Please see screenshot for yopmail:
Anyone can help me out here?
i use the below code to get the text of email body:
Thread.sleep(4000);
driver.switchTo().frame("ifmail");
List<WebElement> elems = driver.findElements(By.cssSelector("div#mailmillieu>div>div[dir='ltr']>div"));
for(WebElement element: elems){
if(!element.getText().equals("")){
System.out.println("body is "+element.getText());
}
}
i use "" as there are some br and new line in my body. But it will show all the text of ur body.
You can give the name as parameter to the switch command
driver.switchTo().frame("ifmail");
Hi please handle iframe like below
driver.switchTo().frame(int arg0); // Select a frame by its (zero-based) index. That is, if a page has multiple frames (more than 1), the first frame would be at index "0", the second at index "1" and so on.
List<WebElement> iframeElements = driver.findElements(By.tagName("iframe"));
System.out.println("The total number of iframes are " + iframeElements.size());
driver.switchTo().frame(String arg0); // Below is the example code snippet using frame
a.Name.
b.Id.
c.WebElement
driver.switchTo().frame(frame);
System.out.println("Navigated to frame with name " + frame);
Switching back to Main page from Frame
driver.switchTo().defaultContent();
Hope this helps you
You can switch to frame by name, id, webelement , index
Here the HTML of frame:-
<iframe class="whc" frameborder="0" scrolling="auto" id="ifmail" name="ifmail" src=""></iframe>
You id and name have the same name so you can switch it as below :-
driver.switchTo().frame("ifmail");
OR
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[#id='ifmail']")));
Hope it will help you :)
Please try as below, hope it helps:
//Switch to Main page first
driver.switchTo().defaultContent();
//Switch to the desired frame
driver.switchTo().frame(frame);
// perform steps you want to do
//and then Switching to Main page again
driver.switchTo().defaultContent();

Obtain data from dynamically incremented IDs in JQuery

I have a quick question about JQuery. I have dynamically generated paragraphs with id's that are incremented. I would like to take information from that page and bring it to my main page. Unfortunately I am unable to read the dynamically generated paragraph IDs to get the values. I am trying this:
var Name = ((data).find("#Name" + id).text());
The ASP.NET code goes like this:
Dim intI As Integer = 0
For Each Item As cItem in alProducts1
Dim pName As New System.Web.UI.HtmlControls.HtmlGenericControl("p")
pName.id = "Name" & intI.toString() pName.InnerText = Item.Name controls.Add(pName) intI += 1
Next
Those name values are the values I want...Name1, name2, name3 and I want to get them individually to put in their own textbox... I'm taking the values from the ASP.NET webpage and putting them into an AJAX page.
Your question is not clear about your exact requirement but you can get the IDs of elements with attr method of jQuery, here is an example:
alert($('selector').attr('id'));
You want to select all the elements with the incrementing ids, right?
// this will select all the elements
// which id starts with 'Name'
(data).find("[id^=Name]")
Thanks for the help everyone. I found the solution today however:
var Name = ($(data).find('#Name' + id.toString()).text());
I forgot the .toString() part and that seems to have made the difference.

How to get multiple value from one textbox?

I have created web application and textbox as a textarea. I am using javascript for validation. When I enter value in text box so it should be number not alphabet I have use textmode is multiple line.
My problem is that how I get multiple value from textbox and store in array in javascript and check each value is number or not. I am using the web form. Please help me.
You can get the value from a textarea like
var txtvalue = document.getElementById("txtareaid").value
and if are using a separator then something like
var txtvaluearray = document.getElementById("txtareaid").value.split(';')
will get you all the values in an array if the seperator is ;
Edit
As per your update you can use \n as the separator and as pointed by #Sohnee you can do the validation.
As addition to rahul:
If you want the values in the textarea seperated by line, you can use \r\n as the splitter.
This is a starter for ten.
var textValues = document.getElementById("mytextarea").value.split("\n");
for (var i = 0; i < textValues.length; i++) {
if (isNaN(textValues[i])) {
alert(textValues[i] + " is not a number.";
}
}

ASP.NET Search on multiple parameters

I am trying to display the results of a search on a gridview.
I want the search to show the results for both last and first name.
I am using ASP.NET with Subsonic and can't figure out how to modify the statemnt below.
I am guessing it needs a wildcard somewhere?
Name: <asp:TextBox ID="txtSearchName" runat="server"></asp:TextBox>
GridView1.DataSource = new Select(PastAwardName.Schema.TableName + ".*", PastAwardType.Schema.TableName + ".*")
.From(PastAwardName.Schema)
.InnerJoin(PastAwardType.Schema.TableName, PastAwardType.Columns.VolID, PastAwardName.Schema.TableName, PastAwardName.Columns.VolID)
.Where(PastAwardName.Columns.LName).IsEqualTo(this.txtSearchName.Text)
.Or(PastAwardName.Columns.FName).IsEqualTo(this.txtSearchName.Text)
.OrderAsc(PastAwardType.Columns.AwardYear)
.ExecuteDataSet();
I think that should work.
Are you familiar with getting the generated SQL from that query?
SubSonic.SqlQuery q = new Select(PastAwardName.Schema.TableName + ".*", PastAwardType.Schema.TableName + ".*")
.From(PastAwardName.Schema)
.InnerJoin(PastAwardType.Schema.TableName, PastAwardType.Columns.VolID, PastAwardName.Schema.TableName, PastAwardName.Columns.VolID)
.Where(PastAwardName.Columns.LName).IsEqualTo(this.txtSearchName.Text)
.Or(PastAwardName.Columns.FName).IsEqualTo(this.txtSearchName.Text)
.OrderAsc(PastAwardType.Columns.AwardYear);
string sql = q.BuildSqlStatement();
Check the value of sql (with a breakpoint on that line) to provide further clues into the problem.
For the wildcard - use the ContainsString() method instead of hardcoding a wildcard like so:
.Where(PastAwardName.Columns.LName).ContainsString(this.txtSearchName.Text)
This will automatically add the provider-specific wildcard character to the beginning and end of the parameter. You can also do StartsWith() and EndsWith().

Resources