Question on ASP.NET

Posted on 2006-03-24
Last Modified: 2010-05-18
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]
                                                      {[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
Question by:nguyenvinhtu
    LVL 5

    Expert Comment

    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..
    LVL 4

    Author Comment

    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(
                                                      DataBinder.Eval(Container, "DataItem.Day01")
                                                 Convert.ToString(DataBinder.Eval(Container, "DataItem.Day01")).IndexOf("$")+1)
                                             ) %>'
         Text='<%# Convert.ToString(
                                                      DataBinder.Eval(Container, "DataItem.Day01")
                                                 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.

    Accepted Solution

    Closed, 300 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now