[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Question on ASP.NET

I am currently making a Manual Payrolling on ASP.NET, what I have to do is showing the payroll table which shape as below.
1 - I call the store procedure to return the table shape like below table.
2 - I bind the Grid to Datasource. Then the table will contain the data like the following table.
3 - On Page I have the code snippet:
<asp:TextBox id=txtDay1 Text='<%# DataBinder.Eval(Container, "DataItem.Day01")%>' >
...
<asp:TextBox id=txtDay1 Text='<%# DataBinder.Eval(Container, "DataItem.Day31")%>' >

|   EmpID    |    March 1    |     March 2    |    ...   |  March 31  |
|   00001    |        8          |       02          |    ...   |       8         |          8 -> Work hour
|   00002    |        02        |       02          |    ...   |       8         |         02 -> Absense code

In the table we will have 8 as "hours of work" and 02 is the "absense code".
My validation on the table is that the user can correct the "work hours", but not on the "absent code". So, the textfield which contain "absense code" should be disabled.

First, Is there any recommedation to quickly solve the problem as I presented above? But it should be adaptable on other situation, for instance, if the user want the absence code to be text like "Absence" or else.
I think I prefer the second way.

The second way is to change the stored procedure/function, that the stored procedure will return a table with data
|   EmpID    |    March1             |     March2              |    ...   |  March31             |
|   00001    |        8$True          |       02$False          |    ...   |       8$True         |          8 -> Work hour
|   00002    |        02$False       |       02$False          |    ...   |       8$True         |         02 -> Absense code

Then on Binding to DataGrid. That means
DataBinder.Eval(Container, "DataItem.Day01") will result 8$True
DataBinder.Eval(Container, "DataItem.Day02") will result 02$False

My idea is to split 8$True into 2 parts like
string[] strA = "8$True".Split("$");
strA[0] = 8
strA[1] = True
so that I can have
<asp:TextBox id=txtDay1 Text='<%#
                                                      {[DataBinder.Eval(Container, "DataItem.Day01")].Split("$")}[0]
                                              %>'
                                     Enabled='<%#
                                                      {[DataBinder.Eval(Container, "DataItem.Day01")].Split("$")}[1]
                                              %>' >
that when Page loaded.
<asp:TextBox id=txtDay1 Text='8' Enabled=True >
<asp:TextBox id=txtDay1 Text='02' Enabled=False >

But I cannot write the code on page.
Hope you understand my idea, I tried a lot.
Thanks and Regards
0
nguyenvinhtu
Asked:
nguyenvinhtu
1 Solution
 
t_itaniumCommented:
hi
before you change the value in the textbox store its value in atemp variable...then check if it is an abscence code...return the old value to the text box else put the new value..
cheers
0
 
nguyenvinhtuAuthor Commented:
Hi everyone, thanks for commenting my question. Now I got a solution for my question.
I don't use Split function but a combination of Substring() and IndexOf(). I'll show you the answer.

<asp:TextBox id=txtDay1
     Enabled='<%# Convert.ToBoolean(
                                       Convert.ToString(
                                                  DataBinder.Eval(Container, "DataItem.Day01")
                                       ).Substring(
                                             Convert.ToString(DataBinder.Eval(Container, "DataItem.Day01")).IndexOf("$")+1)
                                         ) %>'
     Text='<%# Convert.ToString(
                                                  DataBinder.Eval(Container, "DataItem.Day01")
                                       ).Substring(
                                             0,Convert.ToString(DataBinder.Eval(Container, "DataItem.Day01")).IndexOf("$"))
%>' Runat="server">

The answer is rather complex, hope you get my idea. Because I return the string like "8$True" or "02$False", so I use the IndexOf() function to get the position of letter "$", then use Substring() function to cut up the first part for Text value, and second part for Enabled attribute.

Again, I want to thanks to everyone who help me on my topic.
0
 
GranModCommented:
Closed, 300 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now