473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

datagrid,spliting value from database

LU
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2

I have a datagrid that displays values just fine, but user wants to beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id=1sthalf&value=3">3</a> /
<a href="p.aspx?id=2ndhalff&value=4">4</a>
I don't know how to do something like this in the data grid and/or datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!

Nov 19 '05 #1
5 1267
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]

-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id=1sthalf&value=3">3</a> /
<a href="p.aspx?id=2ndhalff&value=4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #2
LU
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]

-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id=1sthalf&value=3">3</a> /
<a href="p.aspx?id=2ndhalff&value=4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #3
<ItemTemplate>
<asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetLeftHalf(Container.DataItem)
%>' Text="LeftHalf" />
<asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetRightHalf(Container.DataItem)
%>' Text="RightHalf" />
</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(object data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}

Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemCommand(object s, DataGridCommandEventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgument;
/// and so on...
}
}

This is very rough as it's off the top of my head, but I think it should
get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This
would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id=1sthalf&value=3">3</a> /
<a href="p.aspx?id=2ndhalff&value=4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #4
LU
This works, but it how do I remove one of them when it only has 1 number and
not 2?
so If i have 3/4 it works, but what about if I have 1 or 10
It seems I will have an extra button.
"Brock Allen" wrote:
<ItemTemplate>
<asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetLeftHalf(Container.DataItem)
%>' Text="LeftHalf" />
<asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetRightHalf(Container.DataItem)
%>' Text="RightHalf" />
</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(object data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}

Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemCommand(object s, DataGridCommandEventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgument;
/// and so on...
}
}

This is very rough as it's off the top of my head, but I think it should
get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:
string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
VAR1 = 3/4
VAR2 = 2
I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
numbers)
when user submits "3/4" we assume 1sthalf/2ndhalf
These values are saved into database as a row
row1: 3/4
row2: 2
I have a datagrid that displays values just fine, but user wants to
beable
to click on the 3 or 4 when we have a "/" in the value.
How do I split the value when it finds a "/" ,
then create a button column(for an event) for each value. This
would
allow
the user to click the 3 "or" 4 in 3/4 and then i could run an event
based on
what they clicked.
so,
I was thinking
<a href="p.aspx?id=1sthalf&value=3">3</a> /
<a href="p.aspx?id=2ndhalff&value=4">4</a>
I don't know how to do something like this in the data grid and/or
datalist.
If it doesn't find a "/" it should assume 1sthalf.
Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #5
You can always add/remove items to the row in the ItemDataBound event of
the grid. In that even you have access to DataGridItemEventArgs.Item so you
can add new controls to use FindContorl to remove or hide existing controls.

-Brock
DevelopMentor
http://staff.develop.com/ballen
This works, but it how do I remove one of them when it only has 1
number and
not 2?
so If i have 3/4 it works, but what about if I have 1 or 10
It seems I will have an extra button.
"Brock Allen" wrote:
<ItemTemplate>

<asp:Button runat=server CommandName="MyButton" CommandArgument='<%#
GetLeftHalf(Container.DataItem)

%>' Text="LeftHalf" />

<asp:Button runat=server CommandName="MyButton" CommandArgument='<%#
GetRightHalf(Container.DataItem)

%>' Text="RightHalf" />

</ItemTemplate>

Where GetLeftHalf:

string GetLeftHalf(object data)
{
string s= (string)data;
return s.Split('/')[0]; // do better error checking that i am here :)
}
Then to handle the click handle the DataGrid's ItemCommand event:

void Grid_ItemCommand(object s, DataGridCommandEventArgs e)
{
if (e.CommandName == "MyButton")
{
string theNumber = e.CommandArgument;
/// and so on...
}
}
This is very rough as it's off the top of my head, but I think it
should get you started in the right direction.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Yes, but how do I make that work inside the datagrid ?

"Brock Allen" wrote:

string s = "3/4";
string[] parts = s.Split('/');
// use parts[0] and parts[1]
-Brock
DevelopMentor
http://staff.develop.com/ballen
> VAR1 = 3/4
> VAR2 = 2
> I user can submit the values "3/4" or "2" (VAR1, VAR2 represent
> any
> numbers)
> when user submits "3/4" we assume 1sthalf/2ndhalf
> These values are saved into database as a row
> row1: 3/4
> row2: 2
> I have a datagrid that displays values just fine, but user wants
> to
> beable
> to click on the 3 or 4 when we have a "/" in the value.
> How do I split the value when it finds a "/" ,
> then create a button column(for an event) for each value. This
> would
> allow
> the user to click the 3 "or" 4 in 3/4 and then i could run an
> event
> based on
> what they clicked.
> so,
> I was thinking
> <a href="p.aspx?id=1sthalf&value=3">3</a> /
> <a href="p.aspx?id=2ndhalff&value=4">4</a>
> I don't know how to do something like this in the data grid and/or
> datalist.
> If it doesn't find a "/" it should assume 1sthalf.
> Any ideas, hints, HELP would be GREAT!


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is...
9
by: Sreejith S S Nair | last post by:
hi there, I have a panel control which contain more than 10 label controls. these label controls are added dynamically by user. In this application user can slit a control into not less than...
0
by: Sreejith S S Nair | last post by:
hi, Setp one. i have one panel control in my form. I am spliting this panel control into two part say working region and holding region. This spliting is only logic spliting. That is i...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.