使用split funtion如何显示数据库中的facname [英] using split funtion how to display the facname from the database
问题描述
教师表记录如下
Facid FacName
1 CAPT。 VIVEK SCUDDER
2 MR。 KRISHNA KUMAR
3 G. SEKHAR
4 VRVENKATESAN
5 AMMATHUR
Bthfac表记录如下
Bthid Bfid Facid
1 1 1,2
2 2 2,3
在运行模式下如下
Facid 1, 2(在下拉列表中)
当我从下拉列表中单击1,2时,我想显示来自Faculty的FacName。 />
输出如下;
当我点击Facid 1,2(在下拉列表中)我要显示文本框中的FacName。
Facid 1,2(在下拉列表中)
CAPT。 VIVEK SCUDDER
MR。 KRISHNA KUMAR
i认为这可以使用split function完成。我是分裂函数的新手。
请帮帮我怎么办?在asp.net中使用C#。
Rgds,
Narasiman P.
HI Narasiman,
我建议你先改进你的数据库设计。留给你的任何方式。
i认为你不必在那里使用Split功能。
您可以直接将昏迷分隔的教师ID传递给您的SP或您的查询,例如
< span class =code-keyword>选择 * 来自教师其中 Facid ( 1 , 2 )
您将获得一个包含2条记录的数据集,然后您可以将此记录绑定到文本框或列表或标签中。
如果您仍想使用拆分,可以使用如下
string [] arrStr = strTempFi lter.Split(' ,');
你会得到一系列字符串
如果你正在使用
string strTempFilter = Facid 1,2 ;
string [] arrStr = strTempFilter.Split(' ,');
arrStr [0] 将有 Facid 1
和 arrStr [1] 将是 2
所以来自 arrStr [0] 你必须修剪 Facid 才能从字符串中获得 1
arrStr [ 0 ] = arrStr [ 0 ]。子串(< span class =code-digit> 4 );
然后你会得到 1 在 arrStr [0]
所以使用 中的值arrStr [0] 和 arrStr [1] 你可以满足你的要求。
继续编码我的朋友。任何混淆plz评论
Faculty table records as follows
Facid FacName
1 CAPT. VIVEK SCUDDER
2 MR. KRISHNA KUMAR
3 G. SEKHAR
4 V.R.VENKATESAN
5 A.M.MATHUR
Bthfac table records as follows
Bthid Bfid Facid
1 1 1,2
2 2 2,3
In run mode as follows
Facid 1,2 (In dropdownlist)
when i click the 1,2 from the dropdownlist i want to display the FacName from the Faculty.
Output as follows;
when i click the Facid 1,2(In dropdownlist) i want to display the FacName in the textbox.
Facid 1,2 (In dropdownlist)
CAPT. VIVEK SCUDDER
MR. KRISHNA KUMAR
i think this can be done using split function.i am new to split function.
please help me how can i do? in asp.net using C#.
Rgds,
Narasiman P.
HI Narasiman,
I suggest you to improve your data base design first.any way that left to you.
i think you dont have to use Split function over there.
you can pass directly the coma separated Faculty id to your SP or your Query like
select * from Faculty where Facid in (1,2)
you will be getting a data set with 2 records then you can bind this record to the text box or list or label where ever you want.
If you still want to use split you can use as below
string[] arrStr= strTempFilter.Split(',');
you will get an array of strings
if you are working with
string strTempFilter="Facid 1,2" ; string[] arrStr= strTempFilter.Split(',');
the arrStr[0] will be having Facid 1
and arrStr[1] will be having 2
so from the arrStr[0] you have to trim Facid to get only 1 from the string
arrStr[0]=arrStr[0].Substring(4);
then you will get 1 in arrStr[0]
so with the values in arrStr[0] and arrStr[1] you can satisfy your requirement.
Keep coding my friend.Any confusions plz comment.
这篇关于使用split funtion如何显示数据库中的facname的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!